Lee Crowe
Feb 2, 2011
  6503
(2 votes)

FilteredPageReference v1.1 Released

I know what you are all thinking, v1.0 was only released 2 days ago.  It must be full of bugs and this is a hasty patch release, but this is not the case, I promise Smile.

I didn’t really see the functionality changing much and I certainly didn’t envisage a new release after 2 days but I had a brain wave yesterday and there was a new feature I wanted to slip in.

For those of you who have not read about my new page picking properties please see my previous post.

The Problem

I am using the new page picking controls for a project I am currently working on.

The project is made up of one code base and many PageType’s but these will be shared amongst many different site instance’s as the site will be released globally.

In all of the sites I have worked on I normally have a Settings page which allows me to set up global site properties such as Site search page link,  Site map page link etc etc.

In this particular project each site will have it’s own settings page having values that obviously differ from site to site.

I would like to be able to set the starting point of the tree for a particular property within a particular page type to point to one of the PageReference properties configured in the settings page but the current implementation of the FilteredPageReference properties does not allow this.

The Solution

I have added a new delegate and a public property to the FilteredPageReference.PropertyFilteredPageReferenceSettings class as follows:

   1:  public delegate PageReference PagePickingStartFromDelegate(PropertyInformation propertyInformation);
   2:   
   3:  public static PagePickingStartFromDelegate StartFromDelegate { get; set; }

I can then set the delegate in code which will allow me to programmatically set the page picking root in code.

If the delegate method returns null or an empty PageReference then the Tree picking settings will be used.  An example of programmatically setting the picking root is below:

   1:  protected void Application_Start(Object sender, EventArgs e)
   2:  {
   3:      FilteredPageReference.PropertyFilteredPageReferenceSettings.StartFromDelegate = SetPagePickingRootPage;
   4:  }
   5:   
   6:  public PageReference SetPagePickingRootPage(FilteredPageReference.PropertyInformation propertyInformation)
   7:  {
   8:      PageDataCollection pages = DataFactory.Instance.GetChildren(PageReference.StartPage);
   9:   
  10:      if (pages.Count == 0)
  11:          return PageReference.EmptyReference;
  12:              
  13:      Random random = new Random();
  14:      int index = random.Next(0, pages.Count - 1);
  15:      return pages[index].PageLink;
  16:  }

The example above is pretty useless but demonstrates the purpose.

The PropertyInformation class which is passed as a parameter to the delegate currently has the following properties:

  • ParentPageId – Parent page id
  • PageId – Page id
  • WorkId – Work id
  • LanguageId – Language id
  • PageTypeId – Page type id
  • PropertyName – Property name

You could then conditionally check properties like the PageTypeId and PropertyName and then set the picking the start the a specific page.

This may or may not be useful to anyone, but I think it’s cool Winking smile

Have feedback?

Please feel free to email or twitter me with any feedback @croweman

Feb 02, 2011

Comments

Aug 1, 2011 12:32 PM

Nice work Crowe. Is there any way you can set-up the "Page Picking Restrictions" programmatically as you can set-up the start up page using the delegate.

Aug 1, 2011 12:35 PM

Hi Tahir

At present there is no way to do this. What are your exact requirements? I am sure it is something I could possibly add quite easily.

Lee

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