Controller not recognized for dashboard single_page

Permalink
Hi guys,

I checked the tutorial on creating single pages and the view file is ok, but the controller is not recognized. Any help is appreciated!

Folder structure:
-- application
---- single_pages
------ dashboard
-------- products
---------- view.php
---- controllers
------ single_page
-------- dashboard
---------- products
------------ controller.php

I did try clearing the cache and refreshing the page in the "Single Pages"

controller.php is not recognized by the view page. I tried to write echo, die or create error and nothing happens.

 
hutman replied on at Permalink Reply
hutman
If you are using 5.7 your Folder structure should look like this:
-- application
---- single_pages
------ dashboard
-------- products.php
---- controllers
------ single_page
-------- dashboard
---------- products.php
alinpop replied on at Permalink Reply
Yes, but what if I want to add multiple pages like dashboard/products, dashboard/add/products, dashboard/edit/products ?

I read some tutorial where they do recommend using folders in such occasions.

In the mean time I will try also your suggestion.
hutman replied on at Permalink Reply
hutman
For 5.7 in those cases you should do something like this:

-- application
---- single_pages
------ dashboard
-------- products
------------ add.php
------------ edit.php
-------- products.php
---- controllers
------ single_page
-------- dashboard
---------- products
-------------- add.php
-------------- edit.php
---------- products.php
alinpop replied on at Permalink Reply
Ok, so I did the changes you suggest and the view and controller run altogether, but:

I cannot set the variable from controller to show in the view.

here is my Controller:

namespace Application\Controller\SinglePage\Dashboard\Products;
use \Concrete\Core\Page\Controller\DashboardPageController;
defined('C5_EXECUTE') or die("Access Denied.");
class Products extends DashboardPageController
{
    public function view()
    { 
        $this->set('variable', 'test');
    }
}


and the view:

echo "VAR = ".$variable;
hutman replied on at Permalink Best Answer Reply
hutman
Your namespace isn't right

namespace Application\Controller\SinglePage\Dashboard;
alinpop replied on at Permalink Reply
Perfect!

Thanks mate!

I tried to follow this tutorialhttps://www.concrete5.org/documentation/developers/5.7/working-with-... but somehow I didn't catch the correct ideas.