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 set a default variable for existing pages?


Go to End


5 Posts   1141 Views

Avatar
SilverRay

Community Member, 167 Posts

12 February 2010 at 1:42am

Edited: 12/02/2010 2:09am

OK, so I know how to set a default value for a variable in newly created pages using:

public static $defaults = array(
	'SomeVariable' => true
);

But how would I do that for existing pages, so *after* they are created, in an existing site for instance? Just set the value manually in the database? (I mean for many pages at once...)

Avatar
baba-papa

Community Member, 279 Posts

15 February 2010 at 12:34pm

Change the code an run [site-url]/dev/build.

Avatar
SilverRay

Community Member, 167 Posts

15 February 2010 at 2:41pm

Hmm, no, that does not set all existing pages' "SomeVariable" to true, unfortunately...

Avatar
bummzack

Community Member, 904 Posts

15 February 2010 at 7:32pm

I think you're best off with changing the value manually in the database.

Avatar
SilverRay

Community Member, 167 Posts

16 February 2010 at 1:11pm

Yeah, I guessed so... thanks though.