Jump to:

5539 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » how to override $defaults with add_extension?

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

Page: 1
Go to End
Author Topic: 1527 Views
  • derralf
    Community Member
    24 Posts

    how to override $defaults with add_extension? Link to this post

    Is it possible to override the defaults array of a page type using add_extension?

    I want to use the blog module as a kind of press-archive and set ProvideComments to false without hacking the module (->future upgrades)

    this is what i tried and its not working:

    in mysite/_config.php:
    DataObject::add_extension('BlogEntry', 'BlogEntryExtension');

    in mysite/code/BlogEntryExtension.php:
    class BlogEntryExtension extends DataObjectDecorator {
       public static $defaults = array(
          "ProvideComments" => false,
          'ShowInMenus' => false

  • Ingo
    Forum Moderator
    801 Posts

    Re: how to override $defaults with add_extension? Link to this post

    You can't override statics like this, please use the extraStatics() method.

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.