Restricting the Episerver Page Types available on the root page

In order to make content editors' lives a lot easier, it's a good idea to restrict the pages that they can create.  This is done using the [AvailableContentType] attribute, on top of your page type definition, if you added the following code then content editors would only be allowed to create child pages of type start page... simple

    [AvailableContentTypes(Include = new[] { typeof(StartPage) })]

In every Episerver website your navigation hierarchy will always start from the Root page: syspage As the root page is an Episerver system type by default, we can't apply the [AvailableContentType] attribute on it so content editors can create any page they want.  This can make life a bit nasty and I've personally seen a lot of navigation trees get very messy, very quickly.  Ideally, you want to limit the root page to have a start page, a container page and maybe a root page.  Luckily there is a way to override the default root page and create our own ones. If you create a page called SysRoot that inherits from PageData, you inject your own propertie into the system root, the code looks something like this:

    [ContentType(GUID = "3415B788-8359-4BF0-9375-2FE9BA90719B",
                 AvailableInEditMode = false)]
    [AvailableContentTypes(Include = new[] {
    public class SysRoot : PageData

That's it.. we have now restricted our pages :)


In today's guide we've talked about the benefits of the types of child pages content editors can create for a more usable back-end.  As the root page of any Episerver site is the beginning of the page hierarchy, then this is the page we need to do something to.  Luckily, Episerver provides a way to override the system behaviour by creating a page called sysroot that implements page data

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