Lee Crowe
Feb 2, 2011
  6565
(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 Forms: You cannot submit this form because an administrator has turned off data storage.

Do not let this error message scare you, the solution is quite simple!

Tomas Hensrud Gulla | Oct 4, 2024 | Syndicated blog

Add your own tools to the Optimizely CMS 12 admin menu

The menus in Optimizely CMS can be extended using a MenuProvider, and using the path parameter you decide what menu you want to add additional menu...

Tomas Hensrud Gulla | Oct 3, 2024 | Syndicated blog

Integrating Optimizely DAM with Your Website

This article is the second in a series about integrating Optimizely DAM with websites. It discusses how to install the necessary package and code t...

Andrew Markham | Sep 28, 2024 | Syndicated blog

Opticon 2024 - highlights

I went to Opticon in Stockholm and here are my brief highlights based on the demos, presentations and roadmaps  Optimizely CMS SaaS will start to...

Daniel Ovaska | Sep 27, 2024