Sub-page single page controller isn't loaded (5.6.3.3)

Permalink
Hi all,

This has been raised before but I haven't found a satisfactory answer.

If I create a single page that isn't an immediate child of the homepage, I can't load its controller. I've checked naming conventions and typos but nothing works:

/single_pages/subpage/test.php
/controllers/subpage/test.php
/single_pages/subpage/test/view.php // Alternative structure
/controllers/subpage/test/controller.php
// Controller code
class testController extends Controller {
    public function test() {
        return "hello";
    }
}
// View code
$test = $this->controller->test();
echo $test;


The output is:

Fatal error: Call to undefined method Controller::test() in /var/www/html/single_pages/test.php


Any thoughts?

melat0nin
 
hutman replied on at Permalink Reply
hutman
In order for this to work you need your Single Page Controller in this folder structure

/controllers/single_page/subpage/test.php

And your Single Page in

/single_pages/subpage/test.php

Then you will need to make sure that the controller starts with

namespace Concrete\Controller\SinglePage\Subpage;
class Test extends Controller{
melat0nin replied on at Permalink Reply
melat0nin
Sorry I should have mentioned I am running 5.6.3.3, so I don't think the namespace stuff comes into it!

Thanks for your reply though :)