Try our conversational search powered by Generative AI!

Lee Crowe
Jun 17, 2011
  4160
(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.

Features

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:

 

Feedback?

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

Disclaimer

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

Comments

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
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog