CreatedPage problem

Vote:
 
Hello, When a page of a certain page type has been created, several pages should be automatically created as children to this page. We have achieved this by using the CreatedPage event. However, after the pages has been created, we need to set a PageReference property on the parent page to reference one of the child pages and then save the parent page. When this is done in the method that executed when CreatedPage fired, the edit mode shows the previously saved version instead of the most current one. The previously saved version does not have the PageReference-property set, so when a user saves the page after creating it, the reference is set to blank again. How could this problem be solved? When creating a page, we need to execute the custom code and show the most recently published version in the edit page directly after creating the page. Thanks / Christoffer
#13013
Apr 18, 2007 15:31
Vote:
 
Do you really need to save the parent page? That is the page from CreatedPage right? If you set a value to a property before it's rendered like you do with a PageReference to a child page it shall be set and visible in the rendered version. If not try the LoadedDefaultPageData event witch is fired after CreatedPage event. I usually use that event if I would like to set some default data on a page, and there is no need to save the PageData object. It will then be saved when the editor chooses to do so. But what happens with the subpage if the editor doesn't save the page, will they be hanging without a parent? /HAXEN
#15249
Apr 18, 2007 20:41
Vote:
 
Thanks, Would it be possible to create and save the child pages before the parent page has been created and saved? When I create the child pages with GetDefaultPageData, I need to supply a ParentPageLink, and in the CreatingPage event, the PageLink property of PageEventArgs is PageReference.EmptyReference because the page has not been saved yet. That's why I need to use the CreatedPage event. The page is saved and all properties are set correctly, but because I set these properites and save the page after the CreatedPage event fired, a new version is created and published. The edit mode still shows the previously version of the page without these new values. Therefore, directly after creating the page, if the users clicks on "Save and publish", the previously published version is saved and the values I set in CreatedPage are deleted. Still looking for a way to solve this. Any suggestions would be greatly appreciated. Regards, Christoffer
#15250
Apr 20, 2007 12:20
Vote:
 
Hi Christoffer! I guess the problem is that your second save of the parentpage creates a new (unpublished) version. I'd suggest you to save the page and force the same version, something like this: EPiServer.Global.EPDataFactory.Save( parentPageData, SaveAction.Save|SaveAction.ForceCurrentVersion); Regards, Johan Olofsson
#15251
Apr 27, 2007 9:47
* 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.