Try our conversational search powered by Generative AI!

Lee Crowe
Feb 2, 2011
(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);
   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:  }
   6:  public PageReference SetPagePickingRootPage(FilteredPageReference.PropertyInformation propertyInformation)
   7:  {
   8:      PageDataCollection pages = DataFactory.Instance.GetChildren(PageReference.StartPage);
  10:      if (pages.Count == 0)
  11:          return PageReference.EmptyReference;
  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


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.


Please login to comment.
Latest blogs
Build a headless blog with Astro and Optimizely SaaS CMS

I’m a big fan of using the right tool for the right job. I’m also a big fan of Astro , for the right use case. Let's explore Astro to see what it's...

Jacob Pretorius | May 28, 2024

Microsoft announces Natural language to SQL

Finally, Microsoft launches "Natural language to SQL," after it has been available for several months in Optimizely CMS!

Tomas Hensrud Gulla | May 23, 2024 | Syndicated blog

Five easy ways to start personalizing your content right now

If you clicked on this article, you already know that getting the right message to the right person at the right time helps drive conversions and...

Kara Andersen | May 23, 2024

ExtendedCms.TinyMceEnhancements – serwer side webp support

Today I will introduce another small feature of TinyMceEnhancements plugin. The functionality is used to automatically detect whether a browser...

Grzegorz Wiecheć | May 22, 2024 | Syndicated blog