AI OnAI Off
http://talk.alfnilsson.se/2013/03/17/simplifying-event-handling-in-episerver-7-cms/
Check out the events for created and published. You registrate event handler in an initializable module. See alloy site for example.
Then try cast page in event handler using as keyword or even better use an interface on the pages you are interested in doing something with and check for that.
[ModuleDependency(typeof(InitializationModule))] public class MyCustomInitModule : IInitializableModule { private IContentEvents _contentEvents; public void Initialize(InitializationEngine context) { if (_contentEvents == null) { _contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>(); } _contentEvents.CreatedContent += ContentEvents_CreatedContent; } private void ContentEvents_CreatedContent(object sender, ContentEventArgs e) { var articlePage = e.Content as ArticlePage; if (articlePage != null) { // TODO: ... } } public void Uninitialize(InitializationEngine context) { if (_contentEvents == null) { _contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>(); } _contentEvents.CreatedContent -= ContentEvents_CreatedContent; } }
Hi
I'm trying to make an event handler that is fired when pages are created inside EPiServer CMS.
When a page is created I want to check if that page is of a specific type, if so I want to pull out some info from it.
How do I make the event handler that is fired when pages are created inside the CMS?
I have looked at this:
http://world.episerver.com/blogs/Shahram-Shahinzadeh/Dates/2010/4/Catch-Monitoring-Event-inside-CMS/
but it does not relates to new created pages.