Concrete 5.7 : Overriding a core single page controller

Overriding a single page controller in Concrete 5.7 is still possible. In some situations you might need to do so. A lot of things have changed in Concrete 5.7 compared to prior versions and one of those things is where to put your overrides.

Let’s say you want to override the page controller for the registration page. The controller for this page (\ Concrete\Controller\SinglePage\Register) is located in the folder /concrete/controllers/single_page/. You will be looking for register.php. So the full filename is : /concrete/controllers/single_page/register.php.

Creating the override
Create a class ‘Register’ in the folder /application/controllers/single_page (you will have to create the subfolder ‘single_page’, it doesn’t exist by default). Now set the namespace of this class to ‘Application\Controller\SinglePage’ and let the controller extend ‘\Concrete\Controller\SinglePage\Register’.

This is what your class will look like:

You can now override or add methods to this class.  In this case I created an override for the on_start method and added the method ‘doSomethingAwesome’.

That’s it, you are all set!