Catch page created event of specific type

Vote:
 

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.

#144972
Feb 23, 2016 13:41
Vote:
 

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.

#144978
Feb 23, 2016 14:19
Vote:
 
[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;
    }
}
#144986
Feb 23, 2016 15:20
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.