Comparing PageTypeBuilder and EPiServer 7 Preview typed pages (part 2 of 3)
Jun 19, 2012
In my previous post I talked about the the "Differences when referencing the page type from a page template". This post describes the mapping between PageType attributes in PageTypeBuilder and typed pages in EPiServer 7 Preview.
The following table shows the mappings for PageTypeBuilder PageType attributes to typed pages in EPiServer 7:
PageTypeBuilder | EPiServer 7 | |||
---|---|---|---|---|
Attribute | Property | Attribute | Property | Comment |
Namespace: PageTypeBuilder | Namespace: EPiServer.DataAnnotations | |||
PageType | - | PageType | - | |
PageType | Guid | PageType | GUID | |
PageType | AvailableInEditMode | PageType | AvailableInEditMode | |
PageType | Description | PageType | Description | |
PageType | Name | PageType | DisplayName | |
PageType | - | PageType | GroupName | If supplied it is added to the display name in admin mode to becomes “[GroupName] DisplayName” |
PageType | SortOrder | PageType | Order | |
PageType | Filename | PageType | N/A | |
PageType | AvailablePageTypes | AvailablePageTypes | Include | |
PageType | ExcludedPageTypes | AvailablePageTypes | Exclude | |
- | AvailablePageTypes | IncludeOn | This page is allowed under parents of this page type | |
- | AvailablePageTypes | ExcludeOn | This page will not be allowed under a parents of this page type |
I personally like the new IncludeOn and ExcludeOn properties as they allow us to specify the page types we want our page type to included underneath (IncludeOn). Or we can stop our page type being created below certain page types (ExcludeOn). This allows us to be more precise with content structures and avoid having to copy/paste lists of page types we want included as children.
Default values
Experienced PageType builder users may have noticed that the following attributes are missing in the mapping table above:
- DefaultArchiveToPageID
- DefaultChildSortOrder
- DefaultFrameID
- DefaultPageName
- DefaultSortIndex
- DefaultStartPublishOffsetMinutes
- DefaultStopPublishOffsetMinutes
- DefaultVisibleInMenu
This is because typed pages in EPiServer 7 does not have direct equivalents. If you want to set default values when using typed pages in EPiServer 7 then you should override the "SetDefaultValues" method on EPiServer.Core.PageData as follows:
public override void SetDefaultValues(PageType pageType) { base.SetDefaultValues(pageType); //Set up your defaults here }
Comparision Example
The following example shows how a PageTypeBuilder page is defined when compared to a EPiServer CMS 7 typed page:
PageTypeBuilder definition
[PageTypeBuilder.PageType("F5E708BE-B8D8-11E1-9F05-EE3A6188709B" AvailableInEditMode = true , AvailablePageTypes = new[] { typeof(AnotherPageType) } , SortOrder = 1234 , Filename = "~/Templates/Public/MyPageType.aspx" , Name = "[Public:Example] My page type" , Description = "The description" , DefaultArchiveToPageID = 2345 , DefaultChildSortOrder = EPiServer.Filters.FilterSortOrder.CreatedDescending , DefaultFrameID = 0 , DefaultPageName = "My page name" , DefaultSortIndex = 9999 , DefaultStartPublishOffsetMinutes = 10 , DefaultStopPublishOffsetMinutes = 20 , DefaultVisibleInMenu = false )] public class YourPageType : PageTypeBuilder.TypedPageData { //Property definitions }
EPiServer 7 definition
[EPiServer.DataAnnotations.PageType( AvailableInEditMode = true , Description = "The description" , DisplayName = "My page type" , GUID = "F5E708BE-B8D8-11E1-9F05-EE3A6188709B" , GroupName = "Public:Example" , Order = 1234)] [EPiServer.DataAnnotations.AvailablePageTypes( Include = new[] { typeof(AnotherPageType) } )] public class YourPageType : EPiServer.Core.PageData { public override void SetDefaultValues(DataAbstraction.PageType pageType) { base.SetDefaultValues(pageType); this.ArchiveLink = new Core.PageReference(2345); this.Properties["PageChildOrderRule"].Value = EPiServer.Filters.FilterSortOrder.CreatedDescending; this.Properties["PageTargetFrame"].Value = 0; this.PageName = "My page name"; this.Properties["PagePeerOrder"].Value = 9999; this.StartPublish = DateTime.Now.AddMinutes(10); this.StopPublish = DateTime.Now.AddMinutes(20); this.VisibleInMenu = false; } //Property definitions }
The structure is different though not that difficult to convert (perhaps another project there!).
In my next post I will compare property mapping in PageTypeBuilder with type pages in EPiServer 7
Part 3 - property mapping in PageTypeBuilder with typed pages in EPiServer 7 »