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

Try our conversational search powered by Generative AI!

CurrentPage in custom property type?

Vote:
 
I was wondering if somebody could help point me in the right direction for getting the CurrentPage in a custom property type? I'm creating a type that needs context on it's position within the website and knowing the CurrentPage value is important. Anyone have any ideas? - JD
#12243
Mar 21, 2005 0:39
Vote:
 
The abstract class that all episerver properties inherit from, PropertyData, has a virtual method called InitializeData. This method has a parameter called properties, which is a PropertyDataCollection. If you write PropertyPageReference pageLinkProperty = properties["PageLink"] as PropertyPageReference if (!pageLinkProperty.IsNull) _pageLink = pageLinkProperty.PageLink; base.InitializeData(config, properties); you shold have the link to the current page. Make _pageLink a private property in the class, so you can access it elsewhere in your class. Frank :)
#13910
Mar 21, 2005 10:05
Vote:
 
I was just trying to figure out how to do this myself and came across this post. I have tried what was suggested by it doesn't work as I am not sure where the property "properties" used in the code above comes from or how to instantiate it. Any ideas?
#13911
Jul 28, 2005 0:28
Vote:
 
Don't worry, figured it out (always happens just after you post the question). You need to override InitializeData and then add the code supplied to the overridden method. Cheers.
#13912
Jul 28, 2005 0:35
* 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.