Is it possible to set default widgets for new pages within silverstripe or have child pages initially inherit their widgets from their parent? The whole side bar is taken up by custom widgets in a site I am working on and it would be nice for a select few to appear by default on the (many) new pages the client will be creating. They should still have the option to remove them or add any of the others.
I have searched the docs and not found any indicators that this is possible.
default widgets should be rather easy to do
We can add a Widget Area to the SiteConfig where you can set the defaults, and then use populateDefaults in Page to copy the widgets from SiteConfig to the new Page:
File
mysite/code/mysiteSiteConfigDecorator.phpFile
mysite/_config.phpFile
mysite/code/Page.phpHowever, coping from the parent isn’t that easy.
But if you want you could also just check if the current Page has widgets, if not, display the parent widgets, like so:
and then use $SidebarForTemplate in templates