views:

156

answers:

1

Hi, I've got a [PageDefinitionTypePlugIn] PropertyString (it's a dropdownlist), and I'd like to be able to detect what it's parent page is. Generally, Global.EPDataFactory.CurrentPage works fine to return the page, but when a NEW page is being created, CurrentPage returns null.

I need to know prior to the render of the control what the parent is, since I'm changing the list of values in the dropdown depending on where the current page is in the navigation heirarchy structure.

Thanks, Lance

+2  A: 
protected void Application_Start( object sender, System.EventArgs e ) {
 EPDataFactory.CreatingPage += new EPiServer.PageEventHandler( OnCreatingPage );
}

private void OnCreatingPage( object sender, EPiServer.PageEventArgs e ) {
  e.TargetLink <-- should be the parent
}
Daniel
Thanks for that Daniel. Is there not an easier way, like some property akin to Global.EPDataFactory.CurrentPage (which is null btw on new pages)? Like maybe something like: Global.EPDataFactory.CurrentPageParent?I notice that the url is missing the 'id' key and instead has a 'parent' key, so it sorta makes sense that Global.EPDataFactory.CurrentPage returns null since there isn't really a page yetThanks,Lance
Lanceomagnifico
Sorry, realised that I read you question wrong :)But I dont think there is an easy way to populate the dropdown without having the currentpage object.A workaroumd could be to have the editors saving the page to just get the property populated. Could you explain a bit more about what is being saved or what they can choose? Maybe there is another approach to the problem
Daniel
The custom property is a dropdown list that is populated with a list of values. The values will change depending where in the document tree the page they are editing is. So I need to know the parent in order to recurse up the tree to find out which set of values to fetch. I've done a workaround by sniffing for 'parent' in the URL, but that's hackey, so was hoping for a 'global' property that I could fetch instead.
Lanceomagnifico