Try our conversational search powered by Generative AI!

Lee Crowe
Feb 2, 2011
  6460
(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
Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog