Single page view and controller dont work fine

Permalink
I dont know how to connect the controller to the view. No error or something like this but the code dont work. I dont find any docs for this issue in Concrete 5.7

I start from very simple example:
Application/single_pages/example.php
<?php 
   echo $myColor;


Application/controllers/example.php
<?php
namespace Application\Controller\SinglePage;
use Concrete\Core\Page\Controller\PageController;
class ExampleController extends Controller {
   public function view(){
         $color=red;
         $this->set('myColor',$color);
   }
}


Last step i Add this single page succsefully inside C5 admin:
dashboard/pages/single/single_page_added

siton
 
mnakalay replied on at Permalink Reply
mnakalay
Hello,
if you correct your code like below it should work:
namespace Application\Controller\SinglePage;
use PageController;
class Example extends PageController {
   public function view(){
         $color=red;
         $this->set('myColor',$color);
   }
}

1- you can simply reference "PageController" instead of the whole path (not an error, just better)
2- Your file is example.php so the class name should be Example, not ExampleController
3- the class should extend PageController, not Controller
siton replied on at Permalink Reply
siton
Ok thanks. This is not working but it seems the system dont know the controller even exist.

Example: Why i dont get any error with code like this?
Application/controllers/example.php
<?php
        ///bad code example
   namespaceeeeeee Application\Controller\SinglePageeeeeeeeeee;
   useeeeee PageControllerrrrrrrrr;
   clllllllllllllass Example extendssssss PageController {
      public function vieeeeeeeeeeeeeeeew(){
         $color=red;
         $ttthis->set('myColor',$colorrrrrrrrr;
      }
   }
mnakalay replied on at Permalink Best Answer Reply
mnakalay
your controller should be in Application/controllers/single_page/example.php not Application/controllers/example.php (you forgot the single_page sub-folder
siton replied on at Permalink Reply
siton
Thanks. This is was my problem, now its work.

How to delete forever unused single pages from this list?
/dashboard/pages/single

I delete some pages from site map and now i see this path:
/!trash/example
mnakalay replied on at Permalink Reply
mnakalay
empty the trash?