November Happy Hour will be moved to Thursday December 5th.

Getting hold of page directory before first save

Vote:
 
Hello. I have a custom property that wants to reach a page's unified directory folder. This is normally done by something like PageReference CurrentPageLink = ((EPiServer.PageBase)Page).CurrentPageLink; PageReference thisPageRef = new PageReference(CurrentPageLink); UnifiedPageDirectory.Get(thisPageRef); But...for new page's (i.e. not yet saved or published), CurrentPageLink refers to nothing (pageID = 0) How to do? Regards
#12356
Sep 08, 2005 17:13
Vote:
 
The code should read: PageReference CurrentPageLink = ((EPiServer.PageBase)container.Page).CurrentPageLink; UnifiedPageDirectory.Get(CurrentPageLink); ...sorry
#14118
Sep 08, 2005 17:15
Vote:
 
You could try something like this (from the sample code): public override void InitializeData(ApplicationConfiguration config, PropertyDataCollection properties) { if (!properties["PageLink"].IsNull) _prPage = (PageReference)properties["PageLink"].Value; else _prPage = (PageReference)properties["PageParentLink"].Value; base.InitializeData (config, properties); } But what I have found is when the page is first created (not saved) "PageLink" does not have a value, but obviously "PageParentLink" does. However, after having a look at the collection of properties in the properties parameter, the new pages folder id is populated "PageFolderID". You could take that ID and do what you need to with the folder. Hope this helps, Jeremy
#14119
Sep 08, 2005 23:18
* 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.