Hello Everyone,
At the heart of the content manager you will find bits of plugin plugin interface codes. Plugins are special resources that are invoked or triggered whenever a system event occurs. In other words a plugin can only be executed whenever the event that it’s listening to is invoked.
There are five system services currently available:
1. Template System Service
2. Manager Access and Security Service
3. Web Access and Security Service
4. Cache Service
5. Parser (Kernel) Services (low level)
Each service can raise an event to alert plugins of a system action that is above to be executed or one that has already been executed. For example, The OnManagerLogin event is immediately after a user logs into the manager. Using this event a plugin can be created to check and log the time and date that a user logins into the system.
Another example is the use of the OnFormPrerender and OnFormRender system event. By listening to these events a plugin can extend the UI of any manager form available within the system. For example, pluginA can be made to listen to the OnUserFormRender and inserts a checkbox at the end of the page whenever the user form is loaded. The value of this check box can be later retrieved when the plugin is called via the OnUserSaveForm event:
$evtname = $modx->Event->name;
swicth ($evtname) {
case "OnUserFormRender": // show checkbox
echo "<input type='checkbox' name='pluginA_checkbox' />";
break;
case "OnUserSaveForm": // get checkbox value
$chkbox = $_POST['pluginA_checkbox'];
// do something here
break;
}
There is no limit to what you can do with plugins and system events.