Plugins & Events

 A plugin allows you to provide complex functionality into your website such as other frameworks, custom global logic, etc. This is done by using provided event script injectors. Each injector can be setup as a component or straight cfm page and configured through a provided plugin.xml file (more on that later) which can be found within each plugin. An example use of these injectors would be if you wanted to alter pre-rendered information that Mura would provide, provide login type scripts that could run whenever a user logs in, etc. If you can name it, you can probably do it with plug-ins.

Here is a list of some of the available events:

  • onGlobalLogin: Fires if there is no site id found within the event. For example this would be used when logging in to the admin.
  • onApplicationLoad: Fires when Mura starts up.
  • onGlobalRequestStart: Fires against every front end content request. This runs before any site logic/object are created or fired.
  • onSiteRequestStart: Fires against every front end site specific content request.
  • onRenderStart: Fires prior to when the rendering process starts.
  • onSiteLogin: Fires when you login to a specific site.
  • onContentDelete: Fires when content is deleted for a specific site.
  • onContentDeleteVersion: Fires when a version of content is deleted for a specific site.
  • onContentDeleteVersionHistory: Fires when you clear the version history for a specific site.
  • onContentSave: Fires when content is saved for a specific site.
  • onContentEdit: Fires when content is edited for a specific site.
  • onUserCreate: Fires when a user is create for a specific site.
  • onUserUpdate: Fires when a user is edited/updated for a specific site.
  • onUserDelete: Fires when a user is deleted for a specific site.
  • onGroupCreate: Fires when a group is created for a specific site.
  • onGroupUpdate: Fires when a group is edited/updated for a specific site.
  • onGroupDelete: Fires when a group is deleted for a specific site.
  • onFeedSave: Fires when a feed is saved for a specific site.
  • onFeedUpdate: Fires when a feed is edited/updated for a specific site.
  • onFeedDelete: Fires when a feed is deleted for a specific site.
  • onSiteEditProfileRender: Fires and renders a custom edit profile form.
  • onSiteSearchRender: Fires and renders a custom site search results.
  • onSiteLoginPromptRender: Fires and renders a custom login form.
  • on{typeBodyRender (onGalleryBodyRender):} Fires when a type is rendered.
  • on{type{subTypeBodyRender (onGalleryProfileRender when profile is an admin defined sub type):}} Fires when a type's sub type is rendered.
  • onContentDenialRender: Fires and renders a custom denial message.
  • onContentOfflineRender: Fires and renders a custom offline message.

As you can see, each event has its own purpose and living spot within the overall rendering/event process. This is important and should be kept in mind as you develop a plugin.

To gain a better grasp on how a plugin works here are a few generic plugins that you can plug into your site. As you will see each plugin is basic zip file. Each file contains a common structure of files and folders. This is key for a successful install of a component into Mura.

Folder and File Structure:

  • displayObjects: This folder is a common container use to store display type objects that you may want to render through your plugin. For example you could build a ticker of sorts and push the display logic into this file, which could then be triggered from the onRenderStart event.
  • eventHandlers: Files found here can either be a cfm or cfc files. As you will see when you intercept an event it requires you to supply a handler/event to hit (scriptFile or component). This is where the logic for those handlers would live. Check out the config.xml file for further details.
  • plugin: This is the plugin config folder
  • config.cfm: This may be removed or depreciated, so leave it in, but disregard.
  • config.xml: You will find yourself in this file the most. It is well documented to help you understand each piece, which could be anything from custom fields available through the plugins admin page to what events you would like to intercept.
  • plugin.cfc: Here you will find the plugin's core events (init, install, update, delete, etc). You will want to use the methods supplied in this file if you require specific logic to run whenever any of associated plugin steps are hit. Note that these are not render type event, rather they are install/setup type events for the plugin itself.
  • index.cfm: This file holds the description of the plugin. Whenever the plugin is installed and the user clicks on the plugin title within the admin console this will be the page they see. You would place credits, how to, links, etc here that would associate to the plugin.

Example Plug-Ins

Hello World

Example Coldspring Plug-In

To install a plugin, go to your site's configuration page (Site Settings in the upper right corner of the Mura admin console) and choose the "Installed Plugins" tab. Install the plug-in. Once it's installed, you can now select which sites it will be available to.

We encourage you to take a look at this example plugin to see how it all flows as plugins will start to play a major role in Mura's flow and overall architecture over time.