Built-in Events

Template events

Template events are dispatched from the blog skins by using the <mango:Event> tag. In addition to the normal Event properties, a TemplateEvent will contain these properties:

requestdata: Everything currently in the request scope
contextdata: when the event is dispatched inside a Post, Comment, or Category, it will contain the tag data.

Its data (event.data) property will also contain an attributes key with any additional information passed to the <mango:Event> tag from the template. You can access this by getting the event.data.attributes key.

beforeHtmlHeadEnd

Dispatched right before the <head> tag is closed. It can be used to add any additional tag inside the HTML head, such as custom style sheets or scripts.

beforeHtmlBodyStart

Dispatched right after the HTML <body> tag is opened.

afterFooterStart

Dispatched right after the tags (ie: <div>) containing the footer are open. Useful for adding content to the beginning of the footer.

beforeFooterEnd

Dispatched right before the tags (ie: <div>) containing the footer are closed. Useful for adding content to the end of the footer.

beforeHtmlBodyEnd

Dispatched right before the <body> tag is closed.

Content management events

Events of this type are dispatched before and after content is added or modified. They are of the type UpdateEvent. In addition to the Event properties, they contain:


oldItem: the item that was updated in its state previous to the update. If this is an "add" event, this item will be empty (verify)
newItem: the updated item (or the new item added)
changeByUser: author object that made the modification

Posts

beforePostAdd

Dispatched when a user tries to add a post. Your plugin has the opportunity here to stop the event if it considers that the post should not be added (ie: doesn't validate, etc).
Data also contains a rawdata property (event.data.rawdata) that contains all the form elements sent by the user. This is empty when user has entered the post via the API.

afterPostAdd

Dispatched after a post has been successfully added. It will contain any additional property that was added in the process (ie: the post ID).
Data also contains a rawdata property (event.data.rawdata) that contains all the form elements sent by the user. This is empty when user has entered the post via the API.

beforePostUpdate

Dispatched when a post is about to be updated.
Data also contains a rawdata property (event.data.rawdata) that contains all the form elements sent by the user. This is empty when user has entered the post via the API.

afterPostUpdate

Dispatched after the post has been updated.

Data also contains a rawdata property (event.data.rawdata) that contains all the form elements sent by the user. This is empty when user has entered the post via the API.

Pages

beforePageAdd

Same as beforePostAdd, but for pages.

afterPageAdd

Same as afterPostAdd, but for pages.

beforePageUpdate

Same as beforePostUpdate, but for pages.

afterPageUpdate

Same as afterPostUpdate, but for pages.

Comments

beforeCommentAdd

Same as beforePostAdd, but for comments.

afterCommentAdd

Same as afterPostAdd, but for comments.

beforeCommentUpdate

Same as beforePostUpdate, but for comments.

afterCommentUpdate

Same as afterPostUpdate, but for comments.

Delete content events


Events of this type are dispatched before and after content is deleted. They are of the type DeleteEvent. In addition to the Event properties, they contain:

oldItem: the item that is to be deleted or was deleted.
changeByUser: author object that made the delete.

Posts

beforePostDelete

Dispatched when a post is about to be deleted.

afterPostDelete

Dispatched after a post was deleted.

Pages

beforePageDelete

Dispatched when a page is about to be deleted.

afterPageDelete

Dispatched after a page was deleted.

Comments

beforeCommentDelete

Dispatched when a comment is about to be deleted.

afterCommentDelete

Dispatched after a comment was deleted.

Getter events


Events of this type are dispatched when an object "getter". These events are used to modify an object properties when they are about to be displayed without modifying the actual object. For example, this type of event is used to add formatting to comments or to add more data to a post body.
They are of the type ObjectAccessEvent. In addition to the Event properties, they contain:

originalObject: the object from which we are trying to retrieve the property. Its properties should not be modified and it is added to the event as a reference.
accessObject: the object the plugin can modify and will be used for property retrieval.

Important: If you want to modify properties before they are displayed, you only change the access object and not the original object.

Posts

 

postGetId

Dispatched before retrieving the post id.

postGetName

Dispatched before retrieving the post name (alias).

postGetTitle

Dispatched before retrieving the post title.

postGetContent

Dispatched before retrieving the post content.

postGetExcerpt

Dispatched before retrieving the post excerpt.

postGetAuthorId

Dispatched before retrieving the post author id.

postGetAuthor

Dispatched before retrieving the post author object.

postGetCommentsAllowed

Dispatched before retrieving the post commentsAllowed property.

postGetStatus

Dispatched before retrieving the post status.

postGetLastModified

Dispatched before retrieving the post last modified date.

postGetUrl

Dispatched before retrieving the post URL.

postGetCommentCount

Dispatched before retrieving the post number of comments.

postGetPostedOn

Dispatched before retrieving the post date posted.

postGetCategories

Dispatched before retrieving the post categories.

postGetCustomField

Dispatched before retrieving a custom field from the post.

Pages

 

pageGetId

Dispatched before retrieving the page id.

pageGetName

Dispatched before retrieving the page name (alias).

pageGetTitle
Dispatched before retrieving the page title.

pageGetContent
Dispatched before retrieving the page content.

postGetExcerpt
Dispatched before retrieving the page excerpt.

pageGetAuthorId
Dispatched before retrieving the page author id.

pageGetAuthor
Dispatched before retrieving the page author object.

pageGetCommentsAllowed
Dispatched before retrieving the page commentsAllowed property.

pageGetStatus
Dispatched before retrieving the page status.

pageGetLastModified
Dispatched before retrieving the page last modified date.

pageGetUrl
Dispatched before retrieving the post's URL.

pageGetCommentCount
Dispatched before retrieving the page number of comments.

pageGetCustomField
Dispatched before retrieving a custom field from the page.

getParentPageId
Dispatched before retrieving the parent id from the page.

getTemplate
Dispatched before retrieving the page template.

getHierarchy
Dispatched before retrieving the page hierarchy.

getSortOrder

Dispatched before retrieving the page sorting order.

 

Comments

commentGetContent

Dispatched before retrieving an comment's content.

commentGetCreatorName

Dispatched before retrieving the name of the person that made the comment.

commentGetCreatorEmail

Dispatched before retrieving the email of the person that made the comment.

commentGetCreatorUrl

Dispatched before retrieving the website address of the person that made the comment.

commentGetCreatedOn

Dispatched before retrieving the date the comment was made

commentGetRating

Dispatched before retrieving the rating of the comment (this property is not currently used)

commentGetApproved

Dispatched before retrieving the "approved" property the comment.

commentGetAuthorId

Dispatched before retrieving the id of the author of the comment (if any)

commentGetParentCommentId

Dispatched before retrieving the id of the parent comment (this property is not currently used)

Collection events


Events of this type are dispatched when a collection is retrieved as a query from the database, right after it has been transformed to objects (posts, pages, comments, etc).
They are of the type CollectionEvent. In addition to the Event properties, they contain:

query: the original query used to create the array of objects
collection: the array of objects
arguments: the arguments passed to the function that was called to get the collection

Posts

getPosts

getPostsByCategory

getPostsByDate

getPostsByAuthor

getPostsByKeyword

getPostById

Pages

Not yet implemented

Comments

Not yet implemented

Administrator menu event

Events of this type are of class AdminMenuEvent.

Property:
links: used to add links to the admin menu

This event also contains a method called "addLink" to add another link to those already in the event. Example:
<cfset link = structnew() />
<cfset link.owner = "yourPluginName">
<cfset link.page = "settings" />
<cfset link.title = "Your Link Name" />
<cfset link.eventName = "showYourPluginSettings" />
<cfset arguments.event.addLink(link)>

Your plugin must also listen to "showYourPluginSettings" event in order to show a page in the admin.

mainNav

Dispatched at the end of the main menu in case plugins want to add links

settingsNav

Dispatched at the end of the sub-navigation in the Setting page of the administrator. 

Other events

In these events you can only modify the request data (passed as event.data property).

beforePostTemplate

Dispatched before a post template is displayed. You can use this event to change the "postTemplate" property if you want to use a different template instead of the default post.cfm from your skin based on some criteria.

beforePageTemplate

Dispatched before a page template is displayed. You can use this event to change the "pageTemplate" property if you want to use a different page template based on some criteria.

beforeIndexTemplate

beforeOuputTemplate

beforeGenericTemplate

beforeAuthorTemplate

beforeArchivesTemplate