This is a cheat sheet for building page types with the Episerver PageTypeBuilder
, I recommend you bookmark it. On a day-to-day basis, I have to create a lot of Episerver page types. When building page types, I always seem to find myself turning to Google as I have forgotten some syntax. I have created this quick reference sheet filled with quick code snippets to help any Episerver developer quickly look up the syntax if they find themselves in the same boat ⛵⛵⛵
The snippet above can be copied and pasted into a class to create an Episerver page type. As you can see I've added the attributes for the page-type level and the attribute level. On the class level, you need to apply the [PageType] attribute. This attribute has several properties you can extend. These include:
Name
: The name that appears in the CMSFilename
: Location to the view fileDefaultChildSortOrder
: The sort orderDescription
: The description in the page type picker within the editorSortOrder
: The order it appear in the page type picker model within the editorAvailablePageTypes
: DEfines what page types a content editor can create below it
To define a property you apply the PageTypeProperty
attribute onto a property. This comes with these properties:
EditCaption
: The property nameHelpText
: The text that appears on the hep icon in the editorSortOrder
: The order the property appears in the editorUniqueValuePerLanguage
: SHoudl the property work with more than one language, or should it default to the default version?Required
: Is the property mandatory. The content editor will not be able to save the page otherwiseSearchable
: Will it be indexed in the searchType
: The backing type, image, string, etc..DefaultValueType
: Default valueTab
: What tab the property appears within
Property DropDownList: Below shows the config required to render a dropdown list
Tab: Below shows the config required to define a custom tab within the editor
Custom Properties: Below shows the config required to create a render a custom property
Cheatsheet over 🎤⬇️💥. Happy Coding 🤘