Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Check out the Publish_ing_Page event instead, it fires *before* the page gets saved to the database, and gives you the chance to make modifications inline to page properties.
For example:
EPiServer.DataFactory.Instance.PublishingPage += new EPiServer.PageEventHandler(DF_PublishingPage);
void DF_PublishingPage(object sender, EPiServer.PageEventArgs e)
{
e.Page.PageName = "Modified " + e.Page.PageName;
}
/johan
Cheers Johan.
Have also found a way of doing it in the PagePublished event:
DataFactory.Instance.Save(writablePage, SaveAction.CheckIn | SaveAction.ForceCurrentVersion);
Yeah, that works too, but requires you to hit the database twice for every page publish.
/johan
I want to automatically update a page property as it gets published.
I have implemented a delegate for the PublishedPage event [EPiServer.Core] - it's firing whenever a page gets published. I can also access the PageData for the published page during the PublishedPage event. No problems there.
What I want to be able to do is update a property on the page that has just been published during the PublishedPage event. I would rather avoid having to create a new published version too.
Have tried creating a writeable clone of the page, changing the property and executing the Save method, but no dice no matter what I use in the SaveAction argument... am I doing something wrong here?
//* Create a writable clone
PageData thisPage = e.Page.CreateWritableClone();
//* Update the property
thisPage["PropertyName"] = "Updated during the PublishedPage event";
//* Save
DataFactory.Instance.Save(myWritablePage, SaveAction.ForceCurrentVersion);
Ta for any pointers...