Episerver : PageTypeBuilder Reference Cheat Sheet

On a day-to-day basis, I have to create a lot of different page types.  I always forget the names of the properties I need or the syntax, so I've created this quick reference sheet filled with quick code snippets.

 
   [PageType(
     Name = "New Template",
     Filename = "~/Templates/Template.aspx",
     DefaultChildSortOrder = EPiServer.Filters.FilterSortOrder.None,
     Description = "Template",
     DefaultPageName = "Template",
     SortOrder = 1,
     DefaultVisibleInMenu = false,
     AvailablePageTypes = new Type[] { typeof(NullPageType) })]
   public class SiteMapPageType : Base.ContentPageBase
    {
        [PageTypeProperty(EditCaption = "Property",
        HelpText = "Property Text",
        SortOrder = 1,
        UniqueValuePerLanguage = false,
        Required = true,
        Searchable = false,
        Type = typeof(EPiImageProperty),
        DefaultValueType = EPiServer.DataAbstraction.DefaultValueType.None,
        Tab = typeof(InformationTab))]
        public virtual PageReference ParentPageLink
        { get; set; }
    }

Useful things to note :
  • Class Declarations :
    • AvailablePageTypes : Allows you to define what child pages can be created:
  • Property Declarations :
    • Tab: Tab Allows you to create a new tab
    • Required : The page won't save unless the property has been set
    • Type : Defines the input type displayed in the CMS, can include EPiImageProperty, PropertyString, PageReference, PropertyDropDownList, EPiServer.SpecializedProperties.PropertyXhtmlString
Property DropDownList Example
        [PropertyDropDownListSettings(Settings = new string[] {
            "|",
            "Option 1|1","Option 2|2",
            "Option  3|3","Option 4|4"})]
        public virtual string DropDownExample
        {
            get;
            set;
        }
Tab Example

using PageTypeBuilder;

namespace PageTypes.Tabs
{
    public class Tab : Tab
    {
        public override string Name
        {
            get { return "Tab"; }
        }

        public override EPiServer.Security.AccessLevel RequiredAccess
        {
            get { return EPiServer.Security.AccessLevel.Read; }
        }

        public override int SortIndex
        {
            get { return 10; }
        }
    }
}

Custom Properties
    [Serializable]
    [DataContract]
    [KnownType(typeof(Video))]
    public class Video
    {
        [MultiplePropertyEntityProperty(Caption = "Vimeo Id",
            Type = typeof(PropertyString),
            SortIndex = 230)]
        [DataMember]
        public string VideoId { get; set; }

        [MultiplePropertyEntityProperty(Caption = "Vimeo Image Url",
            Type = typeof(PropertyImageUrl),
            SortIndex = 240)]
        [DataMember]
        public string VideoImage { get; set; }

        [MultiplePropertyEntityProperty(Caption = "Caption",
            Type = typeof(PropertyString),
            SortIndex = 200, IsInformationProperty = true)]
        [DataMember]
        public string Caption { get; set; }
    }

    [Serializable]
    [CollectionDataContract]
    [KnownType(typeof(Videos))]
    [MultiplePropertyEntity(AddButtonText = "Add new video")]
    public class Videos : List

    [Serializable]
    [PageDefinitionTypePlugIn(DisplayName = "Videos", Description = "Videos")]
    public class VideosProperty : MultiplePropertyBase<Videos, Video>
    {
    }

You can then define your custom property using :

        [PageTypeProperty(EditCaption = "Video section",
            Type = typeof(VideosProperty))]
        public virtual Videos Videos { get; set; }
Using a page type from an aspx page

using INEOS.Web.UI.PageTypes.INEOS;
using PageTypeBuilder.UI;
using System;

namespace INEOS.Web.UI.Templates.INEOS.Pages
{
    public partial class MediaPage :  TemplatePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}


Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge


Back to top
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-35662136-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();