Lee Crowe
Oct 5, 2011
  3766
(3 votes)

FilteredPageReference v1.4 Released

For those of you who are interested but not aware the FilteredPageReference assembly provides a developer with two new properties that are essentially a replacement for the PageReference and LinkItemCollection properties.  These properties allow a developer to restrict what types of pages can be picked and define a page picking start page as well as a few other options.  These settings can be set either through property settings in admin mode or programmatically at runtime.

For more information and links back to previous blog posts see here.

New Features in v1.4

  • The previous version did not work correctly with EPiServer Commerce.  This was because the various handlers used for commerce intercept most .aspx requests and were bypassing my custom VPP handler for embedded resources.  This has been fixed in this version.
  • Pages in the tree that come from custom page providers can now be set as start pages.
  • FilteredPageReference uses a bit of reflection against PageTypeBuilder if you are using it in your project.  This reflective code has now been optimized.
  • In previous versions you could programmatically set the start page based on property information.  This version allows you to also set the allowed page types programmatically.

Installation

Previous versions were built for CMS 6 and onwards.  v1.4 is built specifically against CMS 6 R2 to make use of the new auto mapping DDS functionality for the property settings that are used.

The easiest way to install the assembly is to get it from the EPiServer nuget feed or you can download it from codeplex.

Examples

Below is an example of how you can override the configured start page in code:

  1: public class Global : EPiServer.Global
  2: {
  3:     protected void Application_Start(Object sender, EventArgs e)
  4:     {
  5:         FilteredPageReference.PropertyFilteredPageReferenceSettings.GetPagePickingStartPage = GetPagePickingStartPage;
  6:     }
  7: 
  8:     private void GetPagePickingStartPage(FilteredPageReference.PagePickingStartPage pagePickingStartPage)
  9:     {
 10:         // below are properties available to interigate to determine the start page
 11:         string languageId = pagePickingStartPage.PropertyInformation.LanguageId;
 12:         string pageId = pagePickingStartPage.PropertyInformation.PageId;
 13:         int pageTypeId = pagePickingStartPage.PropertyInformation.PageTypeId;
 14:         string parentPageId = pagePickingStartPage.PropertyInformation.ParentPageId;
 15:         string propertyName = pagePickingStartPage.PropertyInformation.PropertyName;
 16:         int workId = pagePickingStartPage.PropertyInformation.WorkId;
 17: 
 18:         // set the start page, or leave it unset if no override is required
 19:         if (pageTypeId == PageTypeResolver.Instance.GetPageTypeID(typeof(PageTypeOne)).Value &&
 20:             string.Equals(propertyName, new PageTypeOne().GetPropertyName(p => p.PropertyOne)))
 21:         {
 22:             pagePickingStartPage.StartPage = DataFactory.Instance.GetChildren(PageReference.StartPage)[5].PageLink;
 23:         }
 24:     }
 25: }

Below is an example of how you can override the configured allowed page types in code:

  1: public class Global : EPiServer.Global
  2: {
  3:     protected void Application_Start(Object sender, EventArgs e)
  4:     {
  5:         FilteredPageReference.PropertyFilteredPageReferenceSettings.GetAllowedPageTypes = GetAllowedPageTypes;
  6:     }
  7: 
  8:     private void GetAllowedPageTypes(FilteredPageReference.AllowedPageTypes allowedPageTypes)
  9:     {
 10:         // below are properties available to interigate to determine the start page
 11:         string languageId = allowedPageTypes.PropertyInformation.LanguageId;
 12:         string pageId = allowedPageTypes.PropertyInformation.PageId;
 13:         int pageTypeId = allowedPageTypes.PropertyInformation.PageTypeId;
 14:         string parentPageId = allowedPageTypes.PropertyInformation.ParentPageId;
 15:         string propertyName = allowedPageTypes.PropertyInformation.PropertyName;
 16:         int workId = allowedPageTypes.PropertyInformation.WorkId;
 17: 
 18:         // allowed page types can be set either by setting the type array like the following:
 19:         allowedPageTypes.AllowedPageTypesAndInterfaces = new[] { typeof(PageTypeOne), typeof(PageTypeTwo) };
 20: 
 21:         // or page type names can be set by specifying like the following:
 22:         allowedPageTypes.PageTypeNames = PageType.List().Select(current => current.Name).Take(5).ToList();
 23:     }
 24: }

Feedback

Feedback as always is greatly received.  If there are bugs/issues please feel free to email or twitter me @croweman

Oct 05, 2011

Comments

Please login to comment.
Latest blogs
Display Child Pages in Content Delivery API Response

The below example will implement an instance of IContentConverterProvider to customise the serialisation of PageData and output child pages in the...

Minesh Shah (Netcel) | Oct 4, 2022

Bring the Report Center back in Optimizely CMS 12

The Report Center has been a part of Optimizely CMS since its first debut in version 5R2 in 2008, but in CMS 12, it's removed! Don't despair! Make...

Tomas Hensrud Gulla | Oct 4, 2022 | Syndicated blog

Customizing Property Lists in Optimizely CMS

Generic property lists is a cool editorial feature that has gained a lot of popularity - in spite of still being unsupported (officially). But if y...

Allan Thraen | Oct 2, 2022 | Syndicated blog

Optimizely names Luminary Senior Developer, Ynze Nunnink, OMVP

Luminary Senior Developer and Optimizely Lead, Ynze Nunnink has secured the coveted position of Optimizely MVP. Earning a Platinum badge for his...

Ynze | Oct 2, 2022 | Syndicated blog

Content Delivery API – The Case of the Duplicate API Refresh Token

Creating a custom refresh provider to resolve the issues with duplicate tokens in the DXC The post Content Delivery API – The Case of the Duplicate...

David Lewis | Sep 29, 2022 | Syndicated blog

A multi-brand strategy in Optimizely DXP

The Optimizely Digital Experience Platform (DXP) is ideally suited to digital projects featuring multiple websites or applications. Here, we showca...

Ynze | Sep 29, 2022 | Syndicated blog