|Number of votes:||9|
How to define default values for pages and blocks in EPiServer CMS 7
Override the SetDefaultValues method
To set default values for page types and block types you need to override the PageData SetDefaultValues method.
Page type example
We have a page type called ArticleList that have the following properties: SourcePage, MaxNumberOfPages and SortOrder. We want to have the source page default to the start page, the max number of pages to default to 5 and sort order to be alphabetical.
When the editor creates a new page of the type article list the property defaults will be loaded:
As you can see from the example you can also set defaults for the built in properties like visible in menu, child sort order, sort index and stop publish.
Block type example
You can set defaults for blocks in the same way.
What happens if the admin changes the default values in admin mode?
Default values set in admin mode are applied after the SetDefaultValues-method has been called and will thus override your default values defined in code. (Thanks for clearing this up Linus)
Please login to comment.