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.
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.
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 http://doc.silverstripe.com/doku.php?id=tutorial:2-extending-a-basic-site and http://doc.silverstripe.com/doku.php?id=datamodel
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.