Don't miss out Virtual Happy Hour today (April 26).

Try our conversational search powered by Generative AI!

Check if a dynamic property has been specified on the current page

Vote:
 

Hi folks,

I've been trying to find an easy way to determine on which page a dynamic property is set.  Currently I've written a couple of convoluted functions that check to see if the current page has a parent page, and if it does, I compare the values of the dynamic properties to see if they are different.  This continues up the tree until either the root node is reached, or one of the dynamic properties is different.  This works, but I can't help but think that there must be a better way.

Ted Nyberg appears to have a blog entry that answers this particular question (http://labs.episerver.com/en/Blogs/Ted-Nyberg/Tags/Dynamic-Properties/), but the post redirects to his personal blog, which doesn't appear to include the post I'm after.  I've e-mailed Ted to see if I can track it down, but I thought it might be wise to also post the question to the forum.

I've played around with CurrentPage.Property(propertyName).IsDynamicProperty, but this simply tells me if the property is dynamic or not, and doesn't indicate that page on which it is set.  Does anyone have any ideas?

Cheers,

Tim

#54062
Sep 30, 2011 4:41
Vote:
 

Check the DynamicProperty class in the SDK. It seems to have examples that solves this:

http://sdk.episerver.com/library/cms6.1/html/T_EPiServer_DataAbstraction_DynamicProperty.htm

#54063
Sep 30, 2011 7:11
Ted
Vote:
 
#54066
Sep 30, 2011 9:25
Vote:
 

Wonderful.  Thanks folks.  I've marked both responses at the answer because they both answer my convoluted question in different ways.

I've ended up using DynamicProperty.ListForPage to list the properties for the page, and from this I can use InheritedPageLink to figure out which page the property is set on.  However, what I really wanted to figure out was how far up the page tree this might be set, and so, and I compare this to the parent collection from DataFactory.Instance.GetParents.  I think I read somewhere that there's some overhead with using GetParents (as opposed to simply recursively working up the tree page by page).  Is this true?

#54186
Oct 05, 2011 7:02
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.