Skip to content

Events for Developers (v1.x)

Simonas Mikulenas edited this page Dec 3, 2015 · 1 revision

How to Enable Notifications for CMS Actions

The following will allow Better CMS to notify you of certain actions, for example when a page is created:

[...]
using BetterCms.Core;
using BetterCms.Core.Environment.Host;
using BetterCms.Events;

public class MvcApplication : HttpApplication
{
    private static ICmsHost cmsHost;

    protected void Application_Start()
    {
        cmsHost = CmsContext.RegisterHost(); 
        AreaRegistration.RegisterAllAreas();

        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        cmsHost.OnApplicationStart(this); 

        // Attach to the page creation event.
        BetterCms.Events.PageEvents.Instance.PageCreated += Instance_PageCreated;
    }

    // Get notified when page is created.
    void Instance_PageCreated(SingleItemEventArgs<Module.Pages.Models.PageProperties> args)
    {
        // TODO: do what ever is necessary!
    }
[...]

Built-in Better CMS Events

Each Better CMS module can have it's own events. For the main modules, events are described below:

  • BetterCms.Core:

    • BetterCms.Events.CoreEvents.Instance.HostStart
    • BetterCms.Events.CoreEvents.Instance.HostStop
    • BetterCms.Events.CoreEvents.Instance.HostError
    • BetterCms.Events.CoreEvents.Instance.HostAuthenticateRequest
    • BetterCms.Events.CoreEvents.Instance.EntitySaving
    • BetterCms.Events.CoreEvents.Instance.EntityDeleting
  • BetterCms.Module.Root:

    • BetterCms.Events.RootEvents.Instance.PageRendering
    • BetterCms.Events.RootEvents.Instance.PageRetrieved
    • BetterCms.Events.RootEvents.Instance.PageNotFound
    • BetterCms.Events.RootEvents.Instance.PageAccessForbidden
    • BetterCms.Events.RootEvents.Instance.CategoryCreated
    • BetterCms.Events.RootEvents.Instance.CategoryUpdated
    • BetterCms.Events.RootEvents.Instance.CategoryDeleted
    • BetterCms.Events.RootEvents.Instance.TagCreated
    • BetterCms.Events.RootEvents.Instance.TagUpdated
    • BetterCms.Events.RootEvents.Instance.TagDeleted
    • BetterCms.Events.RootEvents.Instance.LanguageCreated
    • BetterCms.Events.RootEvents.Instance.LanguageUpdated
    • BetterCms.Events.RootEvents.Instance.LanguageDeleted
  • BetterCms.Module.Pages:

    • BetterCms.Events.PageEvents.Instance.PageCreated
    • BetterCms.Events.PageEvents.Instance.PageDeleted
    • BetterCms.Events.PageEvents.Instance.PageCloned
    • BetterCms.Events.PageEvents.Instance.PagePropertiesChanging
    • BetterCms.Events.PageEvents.Instance.PagePropertiesChanged
    • BetterCms.Events.PageEvents.Instance.PagePublishStatusChanged
    • BetterCms.Events.PageEvents.Instance.PageSeoStatusChanged
    • BetterCms.Events.PageEvents.Instance.PageContentInserted
    • BetterCms.Events.PageEvents.Instance.PageContentDeleted
    • BetterCms.Events.PageEvents.Instance.PageContentSorted
    • BetterCms.Events.PageEvents.Instance.PageContentConfigured
    • BetterCms.Events.PageEvents.Instance.HtmlContentCreated
    • BetterCms.Events.PageEvents.Instance.HtmlContentUpdated
    • BetterCms.Events.PageEvents.Instance.HtmlContentDeleted
    • BetterCms.Events.PageEvents.Instance.RedirectCreated
    • BetterCms.Events.PageEvents.Instance.RedirectUpdated
    • BetterCms.Events.PageEvents.Instance.RedirectDeleted
    • BetterCms.Events.PageEvents.Instance.WidgetCreated
    • BetterCms.Events.PageEvents.Instance.WidgetUpdated
    • BetterCms.Events.PageEvents.Instance.WidgetDeleted
    • BetterCms.Events.PageEvents.Instance.LayoutCreated
    • BetterCms.Events.PageEvents.Instance.LayoutUpdated
    • BetterCms.Events.PageEvents.Instance.LayoutDeleted
    • BetterCms.Events.SitemapEvents.Instance.SitemapCreated
    • BetterCms.Events.SitemapEvents.Instance.SitemapUpdated
    • BetterCms.Events.SitemapEvents.Instance.SitemapDeleted
    • BetterCms.Events.SitemapEvents.Instance.SitemapNodeCreated
    • BetterCms.Events.SitemapEvents.Instance.SitemapNodeUpdated
    • BetterCms.Events.SitemapEvents.Instance.SitemapNodeDeleted
  • BetterCms.Module.Blog:

    • BetterCms.Events.BlogEvents.Instance.BlogCreated
    • BetterCms.Events.BlogEvents.Instance.BlogUpdated
    • BetterCms.Events.BlogEvents.Instance.BlogDeleted
    • BetterCms.Events.BlogEvents.Instance.AuthorCreated
    • BetterCms.Events.BlogEvents.Instance.AuthorUpdated
    • BetterCms.Events.BlogEvents.Instance.AuthorDeleted
  • BetterCms.Module.MediaManager:

    • BetterCms.Events.MediaManagerEvents.Instance.MediaFileUploaded
    • BetterCms.Events.MediaManagerEvents.Instance.MediaFileUpdated
    • BetterCms.Events.MediaManagerEvents.Instance.MediaFileDeleted
    • BetterCms.Events.MediaManagerEvents.Instance.MediaFolderCreated
    • BetterCms.Events.MediaManagerEvents.Instance.MediaFolderUpdated
    • BetterCms.Events.MediaManagerEvents.Instance.MediaFolderDeleted
    • BetterCms.Events.MediaManagerEvents.Instance.MediaArchived
    • BetterCms.Events.MediaManagerEvents.Instance.MediaUnarchived
  • BetterCms.Module.Newsletter:

    • BetterCms.Events.NewsletterEvents.Instance.SubscriberCreated
    • BetterCms.Events.NewsletterEvents.Instance.SubscriberUpdated
    • BetterCms.Events.NewsletterEvents.Instance.SubscriberDeleted
  • BetterCms.Module.Users:

    • BetterCms.Events.UserEvents.Instance.UserCreated
    • BetterCms.Events.UserEvents.Instance.UserUpdated
    • BetterCms.Events.UserEvents.Instance.UserDeleted
    • BetterCms.Events.UserEvents.Instance.UserProfileUpdated
    • BetterCms.Events.UserEvents.Instance.RoleCreated
    • BetterCms.Events.UserEvents.Instance.RoleUpdated
    • BetterCms.Events.UserEvents.Instance.RoleDeleted
  • BetterCms.Module.LuceneSearch

    • BetterCms.Events.LuceneEvents.Instance.OnDocumentSaving
    • BetterCms.Events.LuceneEvents.Instance.OnSearchQueryExecuting
    • BetterCms.Events.LuceneEvents.Instance.OnSearchResultRetrieving
Clone this wiki locally