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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Populate default data at page creation

Go to End

4 Posts   2575 Views


Community Member, 63 Posts

25 March 2010 at 12:06am


is it possible to have SilverStripe populate a HTMLText field with default data at page creation?

By this I mean when you are in the Admin section and create a new page and choose a page type, it creates the page but also comes with some default data populated. This is so the data can then be changed.

I had a look at the recipe but not sure how to go about having this work for page creation only.


Chris Hope

Community Member, 18 Posts

25 March 2010 at 2:07pm

@silverluke Thanks for your answer. I had already worked out how to populate default stuff for the admin but was wondering how to do a dynamic default.

@BigChris I can't offer any more than silverluke other than to add I've been doing this myself to get some default information into the HTML for a particular page type. You can of course put HTML in the string as well, run it over multiple lines etc e.g.:

static $defaults = array(
'Content' => "<h1>Heading</h1>
<p>Content here</p>
<h2>Some other sort of heading</h2>
<p>Some other sort of content</p>"

Obviously your defaults would be more applicable to the page type than what I've put there :)


Community Member, 63 Posts

27 March 2010 at 10:07pm


Thank you for your help, it did the job.


PHP Engine

Community Member, 2 Posts

5 April 2011 at 9:23pm


Thanks for that - I just thought I'd make an addendum...

I used the above detailed process, and it worked great, only thing was I wanted to pre-populate the Title field in the metadata tab (for the Blog module). So I tried:
static $defaults = array(
'Title' => "My Company | Blog Post | "
which didn't work...
Its because this field is referred to in code as MetaTitle and not Title, even though the label next to the field is Title. Anyways, I found this simply by using firebug, I think the id of the field is the correct name to use in the array key here, but you'll see it clearly.

anyway, the correct answer is here:

static $defaults = array(
'MetaTitle' => "My Company | Blog Post | "

and this was in BlogEntry.php