Before a plugin can respond to an event, the plugin must be loaded. When we normally load plugins we load a group at a time. To do this we use the static JPluginHelper
class.
The following example shows how we would load plugins from the group boxoffice
:
JPluginHelper::importPlugin('boxoffice');
It is essential that we import plugins before firing events that relate to them. There is one time when this does not apply; we never need to import system
plugins. System plugins are imported irrespective of the request that is being handled. It is, however, unlikely that we would ever need to trigger a system event because Joomla! should handle all system events.
So where and when do we import plugins? For starters it does not matter if we attempt to import the same group of plugins more than once. At what point we choose to import the plugins is entirely up to us. The most common place to import plugins is in our component controller.
For example, the search component imports all of...