Lee Crowe
Oct 5, 2011
  4483
(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
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024