Lee Crowe
Oct 5, 2011
  3849
(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
Optimizely SendGrid SMTP host is deprecated

SendGrid is a services for sending email that is included in Optimizely DXP. Previously smtp.episerver.net was the recommended SMTP server to use,...

Tomas Hensrud Gulla | Dec 4, 2022 | Syndicated blog

Hosting Optimizely CMS 12 on Docker Engine

Since Optimizely CMS can now be deployed as a Docker container, here is a demonstration of building, running and scaling an Optimizely CMS 12 site ...

Stefan Holm Olsen | Dec 4, 2022 | Syndicated blog

How to use CacheTagHelper with content areas in Optimizely CMS 12

I might be going out on a limb here - if you have a better solution, feel very free to share it!  Upgrading your Optimizely web application from .N...

Andreas J | Dec 2, 2022

The 1001st Piece in your 1000 Piece Puzzle: .NET Default Interface Functions

I was recently working with a client who wanted a reasonably large subsystem added to Optimizely that would add automated management to their...

Greg J | Nov 28, 2022 | Syndicated blog