Jump to:

3447 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Basic Extending

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

Page: 1
Go to End
Author Topic: 1193 Views
  • Richie
    Community Member
    18 Posts

    Basic Extending Link to this post

    Hi, I want to extend a class and found this example: http://doc.silverstripe.com/doku.php?id=recipes:adding_metatags. This works as expected so I use the same approach on the PageCommentInterface class. My code:

    class CustomCommentInterface extends DataObjectDecorator {
       function CustomCommentForm() {
          return 'Foo';

    DataObject::add_extension('PageCommentInterface', 'CustomCommentInterface.php');

    $CustomCommentForm ('Foo' is not showing up!?)

    Thanks for your time!

    Note. I asked this before but the old forum is archived. I got a reply from howardgrigg (thanks for that!) but I don't want to alter the core.

  • dio5
    Community Member
    501 Posts

    Re: Basic Extending Link to this post


    instead of using a dod for that, I would extend PageCommentInterface directly.

    You'll see that this is called in ContentController.php (around line 300). - see the method 'PageComments'.

    In your Page_Controller you could then do more or less the same:

    function CustomComments() {
          if($this->data() && $this->data()->ProvideComments) {
             return new CustomCommentInterface($this, 'CustomComments', $this->data());
          } else {
             if(isset($_REQUEST['executeForm']) && $_REQUEST['executeForm'] == 'CustomComments.PostCommentForm') {
                echo "Comments have been disabled for this page";

    which gives you the $CustomComments tag in yr template...

    Hope this might help a bit.

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.