Create custom controller for the pageList

Permalink
This issue "using-a-custom-controller-for-a-core-block-type" C5 docs:
http://documentation.concrete5.org/developers/working-with-blocks/w...

I try to create custom controller for the page list and this is not working. I believe i have problems with the names (C5 dont know about this controller).

My custom template location:
application\blocks\page_list\templates\blog-list

And i put the controller her:
application\blocks\page_list\templates\blog-list\controller.php

<?php
//controller.php
namespace Application\Block\PageList; // ** Block or Blocks?
use Concrete\Block\PageList\Controller as PageListBlockController;
class Controller extends PageListBlockController
{
    public function  custom_controller_function ()
    {
       return "bla bla";
    }
}

siton
 
MrKDilkington replied on at Permalink Best Answer Reply
MrKDilkington
Hi siton,

Your controller code looks correct. I believe the problem you are having is caused by the controller file being inside your templates folder (which is for view templates).
http://documentation.concrete5.org/developers/working-with-blocks/w...

After extending the original Page List controller, you can then use the custom_controller_function() in your Page List templates. They do not need their own individual controllers to use the method.
siton replied on at Permalink Reply
siton
Thanks. This was the problem (i put the file inside templates and use wrong namespaces).

The correct code :
application\blocks\page_list\controller.php
<?php
//controller.php
namespace Application\Block\PageList; 
use Concrete\Block\PageList\Controller as PageListBlockController;
class Controller extends PageListBlockController
{
    public function  custom_controller_function ()
    {
       return "bla bla";
    }
}
Nikil replied on at Permalink Reply
How can we run this controller on our website... I mean what will be the URL...?