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.

Data Model Questions /

How to extend Controller


Reply


1756 Views

Avatar
MarijnKampf

Community Member, 164 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 ::::::
   }
}

works.

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?