AI OnAI Off
Hi Jon,
You've got a couple of options for which event to tie in to, depending on whether you want to perform an action before or after the publish has happened.
To hook in to the publish event you'll need one of the following:
DataFactory.Instance.PublishedPage += MyPagePublishedHandler; DataFactory.Instance.PublishingPage += MyPagePublishingHandler;
Then your event handler would look something like this:
private void MyPagePublishingHandler(object sender, PageEventArgs e) { //Do stuff here }
One word of caution though - As I recall (and my memory's awful so this may not be true), initialization modules weren't available in Episerver 6 so you may need to attach the event handler in the Application_Start event either in global.asax or in a custom httpmodule.
Hi,
Thanks for this.
I did manage to get this to work on Episerver 6 R2. I thought Id let you know as im sure ill be looking for this code again :)
[InitializableModule] [ModuleDependency(typeof(EPiServer.Web.InitializationModule))] public class EventsInitialization : IInitializableModule { public void Initialize(InitializationEngine context) { context.InitComplete += InitComplete; } private void InitComplete(object sender, EventArgs e) { EPiServer.DataFactory.Instance.PublishedPage += PublishedContent; } public void Preload(string[] parameters) { } public void Uninitialize(InitializationEngine context) { } private void PublishedContent(object sender, PageEventArgs e) { //DO STUFF HERE } }
[Pasting files is not allowed]
Hi,
Using Episerver 6 R2 is it possible to hook into the Publish event?
Im thinking of using the following code:
But im not sure what i need to add to get the Publish event.
Thanks
Jon