November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi!
You can subscribe to episerver events and react on content change(eg publish). Check this out: https://world.episerver.com/blogs/Daniel-Ovaska/Dates/2019/6/content-events-in-episerver/
Hi Jack,
Yes, you can tie into content events for this purpose. The easiest way is to create an IInitializableModule and, in the "Initialize" method, attach to whichever events you want to listen for (e.g. PublishedContent) like this:
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class PageEventInit : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
contentEvents.PublishedContent += ContentPublishing;
}
private void ContentPublishing(object sender, ContentEventArgs e)
{
// Do stuff here - content which triggered the event is in e.Content
}
public void Uninitialize(InitializationEngine context)
{
var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
contentEvents.PublishedContent -= ContentPublishing;
}
}
Hello!
I cannot find any other problem relating to this query.
Im looking to create an action which runs every time a page is published.
Here I will get the page info etc.
Is there any sort of functionality that exists in Episerver for this?
Thanks!!