Copy page event

Vote:
 
When I create a new page, I can hook into EPDataFactory.PublishedPage in the global.asax.cs and do stuff there, but when I copy and paste a page in edit mode, I dont get into the event. I have also tried EPDataFactory.MovedPage, EPDataFactory.MovingPage and EPDataFactory.SavingPage.
#13264
Mar 25, 2008 18:35
Vote:
 
I've implemented a function that runs when a page is copied. Here's some code: private void EPDataFactory_CreatedPage(object sender, PageEventArgs e) { // According to EPi Dev forum e.Page is null when a page is copied. if(e.Page == null) { PageData page = Global.EPDataFactory.GetPage(e.PageLink, EPiServer.Security.AccessControlList.NoAccess); PageData parentPage = Global.EPDataFactory.GetPage(e.TargetLink, EPiServer.Security.AccessControlList.NoAccess); // Set the pages' archive link to match the parent page.ArchiveLink = parentPage.ArchiveLink; // Depending on if the page ever has been published we publish it again. Otherwise we do a checkin // to avoid publishing pages that wasn't supposed to be published if(page.CheckPublishedStatus(PagePublishedStatus.PublishedIgnoreDates)) { Global.EPDataFactory.Save(page, EPiServer.DataAccess.SaveAction.Publish, EPiServer.Security.AccessControlList.NoAccess); } else { Global.EPDataFactory.Save(page, EPiServer.DataAccess.SaveAction.CheckIn, EPiServer.Security.AccessControlList.NoAccess); } } } Enjoy! Björn Sållarp Avantime AB
#15555
Mar 25, 2008 18: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.