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 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.

Archive /

Our old forums are still available as a read-only archive.

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

Creating pages with default behaviours?

Go to End

3 Posts   3691 Views


Community Member, 9 Posts

20 November 2007 at 7:12pm

Hi I was just wondering if it was possible to create default behaviours for new pages. I am creating some custom pages and I would like for them to have 'show in menu' and 'show in search' turned off by default when they're created.


Forum Moderator, 5523 Posts

20 November 2007 at 7:40pm

Edited: 20/11/2007 7:42pm

you can use $defaults array as a way of setting default values for a page type. Use it the same way as $db or $has_one eg in the Page class you can have

static $defaults = array(
'ProvideComments' => true

so to hide search and menus you could have

static $defaults = array (
'ShowInMenus' = false,
'ShowInSearch' = false

I think / hope thats the right names for the fields. More info on and


Community Member, 9 Posts

20 November 2007 at 10:04pm

Awesome thanks, I double checked the variable names in SiteTree.php and they seem correct so I anticipate that it will work a treat. Much appreciated.