Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » How to extend Controller

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

Page: 1
Go to End
Author Topic: 1667 Views
  • MarijnKampf
    Community Member
    164 Posts

    How to extend Controller Link to this post

    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?

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.