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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

how to override $defaults with add_extension?


Go to End


2 Posts   2120 Views

Avatar
derralf

Community Member, 28 Posts

21 October 2009 at 11:54pm

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
	);	
}

Avatar
Ingo

Forum Moderator, 801 Posts

2 November 2009 at 8:33am

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