Difference between revisions of "Plugin"

From Joomla! Documentation

m (Bad link to Overview was http://dev.joomla.org/content/view/1137/80/|Framework changed to http://docs.joomla.org/Framework)
m (revert)
(29 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Joomla! plugins enable you to execute code in response to certain events, either Joomla! core events or custom events that are triggered from your own code.  This is a powerful way of extending the basic Joomla! functionality.  To see where plugins fit in with the overall Joomla! architecture, look at [http://docs.joomla.org/Framework overview].
+
<noinclude><languages /></noinclude>
 +
<translate>
 +
<!--T:1-->
 +
{{Chunk:Plugin/en}}
  
The Joomla! plugin architecture follows the [http://en.wikipedia.org/wiki/Observer_pattern Observer] design pattern.  The [[JPlugin]] class is derived from [[JObserver]] and provides the means to register custom plugin code with core or custom events.  The [[JEventDispatcher]] class, derived from [[JObservable]], is an event handler which calls all plugins registered for a particular event, when that event is triggered.
+
==Learning More== <!--T:2-->
  
* [[Tutorial:Creating a Plugin for Joomla 1.5]]
+
===Beginner=== <!--T:3-->
* [[How to create a content plugin]]
+
To understand how to install and use a plugin in Joomla it is recommended to read [[Administration of a Plugin in Joomla]]
* [[plugins:using_plugins|How to use plugins in your own code]]
 
* [[Tutorial:Creating an Authentication Plugin for Joomla 1.5]]
 
  
Useful reference: [http://codex.gallery2.org/index.php/Gallery2:Embedding:Event-Based_Loose-Coupled_Integration Gallery 2: Embedding: Event-Based Loose-Coupled Integration]
+
===Intermediate=== <!--T:4-->
 +
To understand plugins better, you should [[S:MyLanguage/Creating_a_Plugin_for_Joomla|create a basic plugin for Joomla!]].
  
Prior to Joomla! 1.5 plugins were known as mambots.  Mambots were able to change content only and were based on certain signal words.  Since then their scope has been stretched and extended to such an extent that to enhance the meaning of the new functionality the developers decided to change the name from mambots to plugins.  Joomla! 1.5 includes legacy support for Joomla! 1.0 mambots.
+
<!--T:5-->
 +
If you have a basic content plugin in a custom module or component, we recommended reading [[Triggering content plugins in your extension]].
  
==Events==
+
===Advanced=== <!--T:6-->
Joomla! ships with a variety of core events, organised into groups. These are described in the following topics.
+
To understand the principles on which the Plugin system works  [[Plugin Developer Overview]]. To then implement this in a component you have designed it is recommended to read [[Supporting plugins in your component]].
  
* [[Reference:System Events for Plugin System|System events]]
+
==Using Plugins== <!--T:7-->
* [[Reference:User Events for Plugin System|User events]]
 
* [[Reference:Editor Events for Plugin System|Editor events]]
 
* [[Reference:Content Events for Plugin System|Content events]]
 
* [[Reference:Contact Events for Plugin System|Contact events]]
 
  
This is an alphabetical list of the core events in Joomla! 1.5 together with the group name to which each belongs. Each event name links to more detailed information.
+
<!--T:8-->
 +
Plugins are grouped together depending on which event they run on. A full list of plugins grouped by event type can be found [[Plugin/Events|here]] (the names of a lot of events changed between {{JVer|1.5}} and {{JVer|2.5}} see [[J2.5:Adapting_a_Joomla_1.5_extension_to_Joomla_2.5#Renamed_Events|here]] for a full list of changes). There are also several simple tutorials on making some sample plugins running on some of these events to help running searches on extensions using both the search and smart search components:
  
* [[Reference:Content Events for Plugin System#onAfterContentSave|onAfterContentSave]] (content)
+
<!--T:9-->
* [[Reference:User Events for Plugin System#onAfterDeleteUser|onAfterDeleteUser]] (user)
+
* [[Creating a search plugin]]
* [[Reference:Content Events for Plugin System#onAfterDisplay|onAfterDisplay]] (content)
+
* [[Creating a Smart Search plug-in]] ({{JVer|2.5}} only)
* [[Reference:Content Events for Plugin System#onAfterDisplayTitle|onAfterDisplayTitle]] (content)
+
 
* [[Reference:Content Events for Plugin System#onAfterDisplayContent|onAfterDisplayContent]] (content)
+
<!--T:10-->
* [[Reference:System Events for Plugin System#onAfterInitialise|onAfterInitialise]] (system)
+
There are further tutorials using the user triggers on how to create an authentication plugin to help users log into Joomla and creating a profile plugin for Joomla.
* [[Reference:System Events for Plugin System#onAfterRoute|onAfterRoute]] (system)
+
 
* [[Reference:System Events for Plugin System#onAfterDispatch|onAfterDispatch]] (system)
+
<!--T:11-->
* [[Reference:System Events for Plugin System#onAfterRender|onAfterRender]] (system)
+
* [[Creating an Authentication Plugin for Joomla]]
* [[Reference:User_Events for Plugin System#onAfterStoreUser|onAfterStoreUser]] (user)
+
* [[Creating a profile plugin]]
* [[Reference:User_Events for Plugin System#onAuthenticate|onAuthenticate]] (authentication)
+
 
* [[Reference:User_Events for Plugin System#onAuthenticateFailure|onAuthenticateFailure]] (authentication)
+
<!--T:12-->
* [[Reference:Content Events for Plugin System#onBeforeContentSave|onBeforeContentSave]] (content)
+
A more complex example of [[Creating a System Plugin to augment JRouter|using plugins to create a new system router]] to produce URLs is also available ({{JVer|2.5}} only).
* [[Reference:User Events for Plugin System#onBeforeDeleteUser|onBeforeDeleteUser]] (user)
+
 
* [[Reference:Content Events for Plugin System#onBeforeDisplay|onBeforeDisplay]] (content)
+
<!--T:13-->
* [[Reference:Content Events for Plugin System#onBeforeDisplayContent|onBeforeDisplayContent]] (content)
+
[[Category:Extensions]][[Category:Landing Pages]][[Category:Glossary]][[Category:JED]]
* [[Reference:User Events for Plugin System#onBeforeStoreUser|onBeforeStoreUser]] (user)
+
</translate>
* [[Reference:Editor Events for Plugin System#onCustomEditorButton|onCustomEditorButton]] (editors-xtd)
 
* [[Reference:Editor Events for Plugin System#onDisplay|onDisplay]] (editors)
 
* [[Reference:Editor Events for Plugin System#onGetContent|onGetContent]] (editors)
 
* [[Reference:Editor Events for Plugin System#onGetInsertMethod|onGetInsertMethod]] (editors)
 
* [[Reference:System Events for Plugin System#onGetWebServices|onGetWebServices]] (xmlrpc)
 
* [[Reference:Editor Events for Plugin System#onInit|onInit]] (editors)
 
* [[Reference:User Events for Plugin System#onLoginUser|onLoginFailure]] (user)
 
* [[Reference:User Events for Plugin System#onLogoutUser|onLogoutFailure]] (user)
 
* [[Reference:User Events for Plugin System#onLoginUser|onLoginUser]] (user)
 
* [[Reference:User Events for Plugin System#onLogoutUser|onLogoutUser]] (user)
 
* [[Reference:Content Events for Plugin System#onPrepareContent|onPrepareContent]] (content)
 
* [[Reference:Editor Events for Plugin System#onSave|onSave]] (editors)
 
* [[Reference:System Events for Plugin System#onSearch|onSearch]] (search)
 
* [[Reference:System Events for Plugin System#onSearchAreas|onSearchAreas]] (search)
 
* [[Reference:Editor Events for Plugin System#onSetContent|onSetContent]] (editors)
 
* [[Reference:Contact Events for Plugin System#onSubmitContact|onSubmitContact]] (contact)
 
* [[Reference:Contact Events for Plugin System#onValidateContact|onValidateContact]] (contact)
 
<noinclude>[[Category:Development]][[Category:Plugins]]</noinclude>
 

Revision as of 20:07, 16 July 2014

Other languages:
Bahasa Indonesia • ‎Deutsch • ‎English • ‎Kiswahili • ‎Nederlands • ‎català • ‎eesti • ‎español • ‎français • ‎italiano • ‎português • ‎português do Brasil • ‎български • ‎中文(台灣)‎ • ‎日本語

A plugin is a kind of Joomla! extension. Plugins provide functions which are associated with trigger events. Joomla provides a set of core plugin events, but any extension can fire (custom) events. When a particular event occurs, all plugin functions of the type associated with the event are executed in sequence. This is a powerful way of extending the functionality of Joomla. It also offers extension developers a way to allow other extensions to respond to their actions, making extensions extensible.

The Joomla! plugin architecture follows the Observer design pattern. The JPlugin class provides the means to register custom plugin code with core or custom events. The JEventDispatcher class is an event handler which calls all plugins registered for a particular event, when that event is triggered. In Joomla 4.x this has been moved to the \Joomla\Event\Dispatcher class in Joomla, and additionally follows the Mediator design pattern

See also: Component, Module, Template


Learning More[edit]

Beginner[edit]

To understand how to install and use a plugin in Joomla it is recommended to read Administration of a Plugin in Joomla

Intermediate[edit]

To understand plugins better, you should create a basic plugin for Joomla!.

If you have a basic content plugin in a custom module or component, we recommended reading Triggering content plugins in your extension.

Advanced[edit]

To understand the principles on which the Plugin system works Plugin Developer Overview. To then implement this in a component you have designed it is recommended to read Supporting plugins in your component.

Using Plugins[edit]

Plugins are grouped together depending on which event they run on. A full list of plugins grouped by event type can be found here (the names of a lot of events changed between Joomla 1.5 and Joomla 2.5 see here for a full list of changes). There are also several simple tutorials on making some sample plugins running on some of these events to help running searches on extensions using both the search and smart search components:

There are further tutorials using the user triggers on how to create an authentication plugin to help users log into Joomla and creating a profile plugin for Joomla.

A more complex example of using plugins to create a new system router to produce URLs is also available (Joomla 2.5 only).