Example Plugin Event Handlers
Plugin event handlers should "mura.plugin.pluginGenericEventHandler
". The example below illustrates how to register the event handler using the onApplicationLoad
event, so that any other Mura events may also be included in the file, and Mura will automatically invoke them when announced, using the pluginConfig.addEventHandler(this)
method.
component extends='mura.plugin.pluginGenericEventHandler' output=false { public any function onApplicationLoad(required struct m) { // Register all event handlers/listeners of this .cfc with Mura CMS variables.pluginConfig.addEventHandler(this); } // Add any event handlers here }
If you wish to register another event handler .CFC file, you can follow the example below.
component extends='mura.plugin.pluginGenericEventHandler' output=false { public any function onApplicationLoad(required struct m) { // Register all event handlers/listeners of this .cfc with Mura CMS variables.pluginConfig.addEventHandler(this); // Register another event handler // Assumes you have a customHandler.cfc located under the same directory. var anotherEventHandler = new customHandler(); variables.pluginConfig.addEventHandler(anotherEventHandler); } // Add any event handlers here }
Register a Custom Model Directory
This example shows how to register a custom "model
" directory.
component extends='mura.plugin.pluginGenericEventHandler' output=false { public any function onApplicationLoad(required struct m) { // Register all event handlers/listeners of this .cfc with Mura CMS variables.pluginConfig.addEventHandler(this); // Register a custom 'model' directory variables.pluginConfig.registerModelDir( dir='path/from/plugin/to/model/dir' ); } // Add any event handlers here }
Register a Custom Display Objects Directory
This example shows how to register a custom "display_objects
" directory.
component extends='mura.plugin.pluginGenericEventHandler' output=false { public any function onApplicationLoad(required struct m) { // Register all event handlers/listeners of this .cfc with Mura CMS variables.pluginConfig.addEventHandler(this); // Register a custom 'model' directory variables.pluginConfig.registerDisplayObjectDir( dir='path/from/plugin/to/display_objects/dir' ); } // Add any event handlers here }
Register a Custom Content Types Directory
This example shows how to register a custom "content_types
" directory.
component extends='mura.plugin.pluginGenericEventHandler' output=false { public any function onApplicationLoad(required struct m) { // Register all event handlers/listeners of this .cfc with Mura CMS variables.pluginConfig.addEventHandler(this); // Register a custom 'content_types' directory variables.pluginConfig.registerContentTypeDir( dir='path/from/plugin/to/content_types/dir' ); } // Add any event handlers here }