A plugin is simply a PHP program that executes at one or more predefined points in the Joomla execution cycle. These points are called events and are triggered from within Joomla. Plugins are tied to events.
Plugins work in three steps,:
1. One or more plugin files are included into the current script, usually with the JPluginHelper::importPlugin() method. Because plugins are normally class declarations, no code is executed at this point.
2. An event is triggered, usually with the $dispatcher- >trigger() method (where $dispatcher is a JDispatcher object). Each event has a name, such as onBeforeInitialise or onContentBeforeSave.
3. The event processing code looks for any enabled plugins that are currently loaded that have a method that matches the event name. If any matching methods are found, they are executed.
Plugins execute when their events are triggered. Joomla events can be thought of as checkpoints along the various paths of the execution cycle. Every time the execution cycle reaches an event checkpoint, the event is triggered. The events are fixed, although different events get triggered depending on what type of execution cycle Joomla is in.
There is only one event for authentication, called onUserAuthenticate. This event is triggered whenever a user attempts to log in to the front or back end of the site.
Captcha is a way to prevent spamming by requiring a user to type some text based on a distorted image of the letters. This is implemented by means of three events: onInit, onDisplay, and onCheckAnswer.
Content events are triggered when content is displayed or edited. This includes articles, contacts, and other types of content.
Editors - XTD
Editors- XTD plugins are used to create the buttons that show below the editors (for example, Image, Pagebreak, and Read More). There is only one event for these plugins, called onDisplay.
This plugin type was introduced in Joomla version 1.6. Extension events are triggered when extensions are installed, uninstalled or edited and saved in the Module, Plugin, Template, or Language Manager.
Search plugins implement the search functionality in Joomla. The core plugins are categories, contacts, content, news feeds, and Web links. The search events are onContentSearchAreas and onContentSearch. The onContentSearchAreas event is used to create an array of content items to search, and the onContentSearch event is used to actually execute the search for each of the content types.
Smart Search (Finder)
The Smart Search plugins are found in the plugins/finder folder. These plugins are used to index the site’s content for use with Smart Search. A plugin is provided for each content type (contacts, content, news feeds, and web links) and can be enabled to allow indexing of this type.
System plugins provide events that are triggered during each Joomla execution cycle. These include onAfterInitialise, the first event triggered in Joomla, and events tied to the render(), dispatch(), and route() methods. System events should be used for plugins that need to be triggered during every execution cycle, regardless of which task is being performed.
User events are triggered during two different tasks. One group of events is tied to editing user information in the User Manager. These include onUserAfterDelete, onUserAfterSave, onUserBeforeDelete, and onUserBeforeSave. A second group of events is related to logging on and off the site. These include onUserLogin and onUserLogout.
Naming Conventions for Plugins
For plugins to be found by the JPluginHelper::importPlugin() method, you need to follow the correct naming conventions for the plugin file and class names. Plugin folder and file names are created as follows:
plugins/<plugin type>/<plugin name>/<plugin name>.php
For example, the SEF file is plugins/system/sef/sef.php. Plugins have an XML file with the same name (for example, plugins/system/sef/sef.xml).