Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to extend Controller

Go to End



Community Member, 176 Posts

30 March 2010 at 5:20am

Edited: 30/03/2010 5:21am

I've been working on an extension that will allow for multiple comment areas on a single page. I've got it working, and most of the functionality is all neatly contained within the extension. However, I've created three functions that are used within the templates, to specify where the comment areas should be defined.

Currently the only way I can get it to work is to define them in the _Controller class of the Page class I'm using in my system:

class Species_Controller extends Page_Controller {
	function PageComments($location = null) {
		:::::: code ::::::


If I try to extend the Extension class

class PageCommentMulti_Controller extends Extension {
	function PageComments($location = null) {
		:::::: code ::::::

and add that to the controller in the _config.php
Object::add_extension('Species_Controller', 'PageCommentMulti_Controller');

it doesn't work. There are no errors, the functionality just isn't shown in the templates.

Is there a way to extract/abstract the Controller class allowing the functionality to be easily implemented in other systems and for other classes, without having to define the Controller functions manually?