Event hooks

Table of contents

Event hooks allow you to replace or extend Masa CMS’s logic and functionality. They are written as a function that is part of an event handler.

public any function onEvent(m) {
  // write logic/functionality here
}

Inside the function, the Masa Scope is available as a argument.

Event hook naming

The name of an event hook is descriptive and already gives away a lot of information regarding it’s purpose.

Event prefixes

  • standard{Event}: these events replace existing logic or functionality.
  • on{Event}: these events allow for you to add logic or functionality.

Global or Site

  • onGlobal{Event}: these events are triggered throughout the entire instance of Masa CMS.
  • onSite{Event}: these events are only triggered in relation to the site they are registered to.

Before or After

  • onBefore{Event}: these events are triggered before Masa CMS executes it’s functionality.
  • onAfter{Event}: these events are triggered after Masa CMS executes it’s functionality.

Standard events

Event Description
standard404Handler  
standard404Validator  
standardDoActionsHandler  
standardDoResponseHandler  
standardEnableLockdownHandler  
standardEnableLockdownValidator  
standardFileTranslationHandler  
standardFileTranslator  
standardForceSSLHandler  
standardForceSSLValidator  
standardJSONTranslator  
standardLinkTranslationHandler  
standardLinkTranslator  
standardMobileHandler  
standardMobileValidator  
standardPostLogoutHandler  
standardRequireLoginHandler  
standardRequireLoginValidator  
standardSetContentHandler  
standardSetIsOnDisplayHandler  
standardSetLocaleHandler  
standardSetPermissionsHandler  
standardSetPreviewHandler  
standardTrackSessionHandler  
standardTrackSessionValidator  
standardTranslationHandler  
standardWrongDomainValidator  
standardWrongFilenameHandler  
standardWrongFilenameValidato  

Analogous CFML Application Events

Event Analogous CFML Application Event Description
onApplicationLoad onApplicationStart  
onGlobalSessionStart onRequestStart announced only if session management is enabled, and request.doMuraGlobalSessionStart is true.
onGlobalSessionEnd onSessionEnd announced only if session.siteid is not defined.
onSiteSessionEnd onSessionEnd announced only if session.siteid is defined.
onGlobalRequestStart onRequestStart  
onGlobalRequestEnd onRequestEnd  
onGlobalMissingTemplate onMissingTemplate announced only if siteid is not defined in the event.
onSiteMissingTemplate onMissingTemplate announced only if siteid is defined in the event.
onGlobalError onError announced only if siteid is not defined in the event.
onSiteError onError announced only if siteid is defined in the event.

Administration Events

Event Description
onBeforeAutoUpdate  
onAfterAutoUpdate  
onGlobalThreatDetect  
onAdminRequestStart  
onAdminRequestEnd  
onSiteDeploy  
onBeforeSiteDeploy  
onAfterSiteDeploy  
onAfterSiteDeployRender  
onSiteCopy  
onBeforeSiteUpdate  
onBeforeSiteSave  
onAfterSiteUpdate  
onAfterSiteSave  
onBeforeSiteDelete  
onAfterSiteDelete  
onBeforeSiteCreate  
onAfterSiteCreate  
onBeforeSiteEmptyTrash  
onBeforeGlobalEmptyTrash  
onAfterSiteEmptyTrash  
onAfterGlobalEmptyTrash  
onBeforeProxyBundleDeploy  
onAfterProxyBundleDeploy  
onBeforeChangeSetPublish  
onAfterChangeSetPublish  
onAfterChangeSetPublishError  

Administration Area Rendering Events

Event Description
onDashboardReplacement  
onDashboardPrimaryTop  
onDashboardPrimaryBottom  
onDashboardSidebarTop  
onDashboardSidebarBottom  
onAdminNavMainRender  
onFEToolbarExtensionRender  
onAdminHTMLHeadRender  
onAdminHTMLFootRender  
onAdminMFAChallengeRender  
onContentSecondaryNavRender  
on{Type}SecondaryNavRender  
on{Type}{Subtype}SecondaryNavRender  
onNewContentMenuRender  
on{Type}{Subtype}NewContentMenuRender  

JSON API Events

Event Description
onAPIResponse  
on{Type}APIResponse  
on{Type}{Subtype}APIResponse  
onAPIError  
onSiteAsyncRequestStart  
onAsyncRenderStart  

Content Editing Events

Event Description
onBeforeContentSave  
onBefore{Type}Save  
onBefore{Type}{Subtype}Save  
onAfterContentSave  
onAfter{Type}Save  
onAfter{Type}{Subtype}Save  
onBeforeContentDelete  
onBefore{Type}Delete  
onBefore{Type}{Subtype}Delete  
onContentDelete  
on{Type}Delete  
on{Type}{Subtype}Delete  
onAfterContentDelete  
onAfter{Type}Delete  
onAfter{Type}{Subtype}Delete  

Content Version History Events

Event Description
onContentDeleteVersionHistory  
onBeforeContentDeleteVersionHistory  
onBefore{Type}DeleteVersionHistory  
onBefore{Type}{Subtype}DeleteVersionHistory  
onBefore{Type}{Subtype}DeleteVersion  
on{Type}DeleteVersionHistory  
on{Type}{Subtype}DeleteVersionHistory  
onAfterContentDeleteVersionHistory  
onAfter{Type}DeleteVersionHistory  
onAfter{Type}{Subtype}DeleteVersionHistory  
onContentDeleteVersion  
onBeforeContentDeleteVersion  
onBefore{Type}DeleteVersion  
onBefore{Type}{Subtype}DeleteVersion  
onAfterContentDeleteVersion  
onAfter{Type}DeleteVersion  
onAfter{Type}{Subtype}DeleteVersion  

Content Rendering Events

Event Description
onSite404  
onSiteCKEditorConfigRender  
onSiteCKFinderConfig Removed in 7.3
onContentEdit  
on{Type}Edit  
on{Type}{Subtype}Edit  
onContentEditMessageRender  
on{Type}EditMessageRender  
on{Type}{Subtype}EditMessageRender  
onFeedEditMessageRender  

Comments Events

Event Description
onBeforeCommentCreate  
onBeforeCommentSave  
onBeforeCommentUpdate  
onBeforeCommentDelete  
onAfterCommentCreate  
onAfterCommentSave  
onAfterCommentUpdate  
onAfterCommentDelete  
onBeforeCommentUndelete  
onAfterCommentUndelete  
onBeforeCommentFlag  
onAfterCommentFlag  
onBeforeCommentMarkAsSpam  
onAfterCommentMarkAsSpam  
onBeforeCommentUnMarkAsSpam  
onAfterCommentUnMarkAsSpam  

Category Events

Event Description
onBeforeCategoryCreate  
onBeforeCategorySave  
onBeforeCategoryUpdate  
onBeforeCategoryDelete  
onAfterCategoryCreate  
onAfterCategorySave  
onAfterCategoryUpdate  
onAfterCategoryDelete  

File-specific Events

Event Description
onFileEdit  
onFileDefaultEdit  
onBeforeFileCache  
onFileCache  
onAfterFileCache  
onFileCacheDelete  
onBeforeFileCacheDelete  
onAfterFileCacheDelete  
onBeforeFileRender  
onAfterFileRender  
onBeforeFilenameCreate  
onAfterFilenameCreate  
onBeforeImageManipulation  
onAfterImageManipulation  
onAfterFileResize New in 7.3
onAfterFileDuplicate New in 7.3
onAfterFileRotate New in 7.3
onAfterFileCrop New in 7.3
onAfterFileUpload New in 7.3
onAfterFileEdit New in 7.3
onAfterFileUpdate New in 7.3
onAfterFileDelete New in 7.3
onAfterFileRename New in 7.3

Form-specific Events

Event Description
onFormElementBasicTabRender  
onForm{Subtype}BodyRender  
onBeforeFormSubmitSave  
onBeforeForm{Subtype}SubmitSave  
onAfterFormSubmitSave  
onAfterForm{Subtype}SubmitSave  
onFormSubmitErrorRender  
onFormSubmitResponseRender  
onBeforeFormSubmitRedirect  

Feed-specific Events

Event Description
onBeforeFeedCreate  
onBeforeFeedSave  
onBeforeFeedUpdate  
onBeforeFeedDelete  
onFeedCreate  
onFeedSave  
onFeedUpdate  
onFeedDelete  
onAfterFeedCreate  
onAfterFeedSave  
onAfterFeedUpdate  
onAfterFeedDelete  

User Editing Events

Event Description
onBeforeUserCreate  
onBeforeUserUpdate  
onBeforeUserSave  
onBeforeUserDelete  
onBeforeUser{Subtype}Create  
onBeforeUser{Subtype}Update  
onBeforeUser{Subtype}Save  
onBeforeUser{Subtype}Delete  
onUserCreate  
onUserUpdate  
onUserSave  
onUserDelete  
onAfterUserCreate  
onAfterUserUpdate  
onAfterUserSave  
onAfterUserDelete  
onAfterUser{Subtype}Create  
onAfterUser{Subtype}Update  
onAfterUser{Subtype}Save  
onAfterUser{Subtype}Delete  

Group Editing Events

Event Description
onBeforeGroupCreate  
onBeforeGroupUpdate  
onBeforeGroupSave  
onBeforeGroupDelete  
onBeforeGroup{Subtype}Create  
onBeforeGroup{Subtype}Update  
onBeforeGroup{Subtype}Save  
onBeforeGroup{Subtype}Delete  
onGroupCreate  
onGroupUpdate  
onGroupSave  
onGroupDelete  
onGroup{Subtype}Create  
onGroup{Subtype}Update  
onGroup{Subtype}Save  
onGroup{Subtype}Delete  
onAfterGroup{Subtype}Create  
onAfterGroup{Subtype}Update  
onAfterGroup{Subtype}Save  
onAfterGroup{Subtype}Delete  

Group & User Rendering Events

Event Description
onGroupEdit  
onUserEdit  
Event Description
onSiteLogin  
onSiteLoginSuccess  
onSiteLoginFailure  
onSiteLoginBlocked  
onSiteLogout  
onBeforeSiteLogout  
onAfterSiteLogout  
onGlobalLogin  
onGlobalLoginSuccess  
onGlobalLoginFailure  
onGlobalLoginBlocked  
onGlobalLogout  
onBeforeGlobalLogout  
onAfterGlobalLogout  
onSiteEditProfileRender  
onSiteLoginPromptRender  
onContentDenialRender  
onAdminMFAChallengeRender  
onSiteMFAChallengeRender  
onMFAAttemptChallenge  

Custom events

When developing for Masa CMS, you can create your own event hooks. This might allow for nicely structured code or even opening up your functionality to other developers.

Announcing events

Annoucing an event informs Masa CMS that something specific occured and it will look up the corresponding event hooks in the registered event handlers.

m.announceEvent('onYourEvent', m);

Rendering events

If you want your event to render to the browser, make sure your event hook returns it and call the event using the renderEvent method.

m.renderEvent('YourEvent');