November Happy Hour will be moved to Thursday December 5th.

Lee Crowe
Oct 5, 2011
  4591
(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 SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Set Default Culture in Optimizely CMS 12

Take control over culture-specific operations like date and time formatting.

Tomas Hensrud Gulla | Nov 15, 2024 | Syndicated blog

I'm running Optimizely CMS on .NET 9!

It works 🎉

Tomas Hensrud Gulla | Nov 12, 2024 | Syndicated blog

Recraft's image generation with AI-Assistant for Optimizely

Recraft V3 model is outperforming all other models in the image generation space and we are happy to share: Recraft's new model is now available fo...

Luc Gosso (MVP) | Nov 8, 2024 | Syndicated blog