In our SharePoint project, we have a page layout in which the user can set a custom checkbox (“Show as news”) in edit mode. Now our customer asked if we can have this checkbox set to checked per default.
The checkbox is realised as a <SharePointWebControls:BooleanField> in the layout page, with a corresponding <Field Type="Boolean"> in the sitecolumns definition.
I tried adding a <Default>1</Default> to the sitecolumn definition, and together with changing the default value for the site column through SiteSettings, this worked and the checkbox appeared as checked by default for new pages. However, we have other layouts which also use that field (same content type) and for which we don’t want to have the value checked per default.
So, my idea was to set the field value in an event receiver if a page is created. The receiver is called correctly and the item is available, however I can’t seem to find a way to determine the page layout from the item I get through the event properties. I tried accessing the layout directly through the field item["PublishingPageLayout"] and also by getting the page as PublishingPage, then calling publishingPage.Layout.Name but in both cases there is no value available (null) for the layout.
I’d be glad if anyone could suggest an alternative way to find out the layout. Or maybe completely other way to achieve what I want.
Other way to achieve what you want:
Create a new content type based on this one. The new content type will have the checkbox checked by default and will only be used for this list. This way the other layouts will not be affected and will work independently.
Hope this helps?