Lee Crowe
Jun 17, 2011
(5 votes)

Introducing EPiServer PageTypeExtensions v1.0

A few months ago I was working on a project that had the requirement to restrict the number of pages of specific types that could be created beneath a page of a specific type.

I also had a need to not allow any pages under a page type.  But EPiServer currently doesn’t support this.  If you don’t explicitly select available page types then all page types will be available.

A couple of weeks ago I decided to revisit the code I wrote for this and make it available via an open source project.

The restrictions were enforced by hooking into DataFactory events such as creating, moving, saving, and publishing pages.

I decided to enhance the functionality and create a new version of the NewPage.aspx page.  This page would filter the available page types by checking the various configured restrictions.

After I implemented the necessary functionality for page type restrictions I recalled a blog post David Knipe wrote a year ago about enhancing the Create New Screen.  I thought while I was on the subject of building something that replaces the Create New page I could bolt in some thumbnail and preview image functionality.

Setup and Installation

Please refer to this document for detailed instructions on setup and usage.  The runtime binaries and source code can be downloaded from codeplex.


Below I will give a quick summary on the features available and how to use them.  Please refer to this document for more detailed instructions on how to use the features available.

Page Type Restrictions

The page type restrictions functionality is dependent on PageTypeBuilder and allows a developer to restrict page types that can be created under particular page types.  The rules can be setup by decorating page type classes with PageTypeRestriction attributes.  Examples are below:

1. Specify that no children can be created under a page type named “Parent”.

[PageTypeRestriction(NumberOfAllowedChildren = 0)]
public class Parent : TypedPageData

2. Specify that a total of 5 pages can be created under a page type named “Parent”.

[PageTypeRestriction(NumberOfAllowedChildren = 5)]
public class Parent : TypedPageData

3. Specify that no instances of a page type named “Child” can be created under a page type named “Parent”.

[PageTypeRestriction(ChildPageTypeTypes = new[] { typeof(Child) }, NumberOfAllowedChildren = 0)]
public class Parent : TypedPageData

4. Specify that only 5 instances of a page type named “Child” and 1 instance of a page type named “ChildTwo” can be created under a page type named “Parent”.

[PageTypeRestriction(ChildPageTypeTypes = new[] { typeof(Child) }, NumberOfAllowedChildren = 5)]
[PageTypeRestriction(ChildPageTypeTypes = new[] { typeof(ChildTwo) }, NumberOfAllowedChildren = 1)]
public class Parent : TypedPageData

5. Specify that only 5 instances of a page type named “Child” and a page type named “ChildTwo” can be created under a page type named “Parent”.

[PageTypeRestriction(ChildPageTypeTypes = new[] { typeof(Child), typeof(ChildTwo) }, 
        NumberOfAllowedChildren = 5)]
public class Parent : TypedPageData


Thumbnail and Preview Images on Create New Page

This is a feature more people will probably be interested in.  There are many configuration settings that can be configured within the PageTypeExtensions.config file (please refer to usage instructions for more information) which allow you to configure thumbnail and preview images for the create new  page.

Put simply the new version of the create new page will get page type thumbnail and preview images from the VPP.

There is a scheduled job, an administration tool and right click tree view functionality which can be exploited to allow automatic generation of web page images.

Web page images are generated using IECapt but alternative capture tools/web services could be used by modifying the value of the webPageImageGeneratorType configuration attribute.

When creating images for page types, by default the last published page saved of a particular page type will be used for the image capture. It is possible to specify a particular page of a particular page type to use for the image capture. You can do this by adding a Boolean property to your page type with the same name as the value defined in the useForImagePreviewPropertyName configuration attribute. The editor then needs to set this property value to true on the page they want to use. If no page can be found with the property value set to true then the latest published save page will be used.

Examples of the updated NewPage.aspx which is used for creating pages from page types are shown below:



I am always eager to receive feedback good and bad. 

Please feel free to email or twitter me with any feedback @croweman or comment on the blog post Smile


Although I have tested the assembly and am happy with it’s functioning there may well be little bugs that I have not spotted.  Please give it a thorough test before releasing it to the production environment and log any issues on codeplex.

Jun 17, 2011


Joshua Folkerts
Joshua Folkerts Jun 17, 2011 04:25 PM

Very nice.

Jun 18, 2011 12:12 AM

Yes very nice! Maybe something you can incorporate with your tab-ordering Joshua?

Joshua Folkerts
Joshua Folkerts Jun 23, 2011 04:00 AM

Most certainly.

Please login to comment.
Latest blogs
Preview multiple Visitor Groups directly while browsing your Optimizely site

Visitor groups are great - it's an easy way to add personalization towards market segments to your site. But it does come with it's own set of...

Allan Thraen | Sep 26, 2022 | Syndicated blog

The Report Center is finally back in Optimizely CMS 12

With Episerver.CMS.UI 12.12.0 the Report Center is finally re-introduced in the core product.

Tomas Hensrud Gulla | Sep 26, 2022 | Syndicated blog

Dynamic Route in ASP.NET Core When MapDynamicControllerRoute Does Not Work

Background Creating one of the add-on for Optimizely I had to deal with challenge to register dynamically route for the API controller. Dynamic rou...

valdis | Sep 25, 2022 | Syndicated blog

404 Error on Static Assets Within an Optimizely plugin

Background With the move to CMS 12 and .NET 5/6, developers are now able to build Plugins and Extensions using Razor Class Libraries (RCL).  These...

Mark Stott | Sep 23, 2022

How to bypass the content creation view in Optimizely

Something that has come up a couple of times in the last few year is feedback from content editors about the editing view that comes up when creati...

Ynze | Sep 23, 2022 | Syndicated blog

Welcome to Optimizely World's New Tech Video Portal

Optimizely, leader in the digital experience realm, has become a wealth of world class SaaS products including Web Experimentation, Full Stack, B2B...

The Developer Marketing Team of Optimizely | Sep 22, 2022