Eyenet Designs Eyenet Designs

Home / Blog & News / Blog / Joomla Event Methods

Joomla Event Methods

Plug-ins in Joomla can respond to any number of events during a request.

Multiple plug-ins can respond to any one event in their group. The ordering of the plug-ins in Joomla's back end determines the order which registered functions are called. For instance, if both plug-in A and plug-in B respond to onBeforeDisplayContent, A's function registered with onBeforeDisplayContent will be called first.

A listing of when these events occur, grouped by plug-in type is as follows:


Authentication plugins are used to authenticate a user's login details. Joomla! supports four different authentication methods... GMail, Joomla, LDAP and OpenID

  • onAuthenticate: Triggered when a user attempts to log in, this event is used to authenticate user credentials.

The content plugins allow us to modify content items before we display them. The most commonly used content event is onPrepareContent. This event, always the first of all the content events to be triggered, is used to modify the text content.

  • onAfterDisplayContent: Creates an XHTML string, which is displayed directly after the content item.
  • onAfterDisplayTitle: Creates an XHTML string, which is displayed directly after the content item title.
  • onBeforeDisplayContent: Creates an XHTML string, which is displayed directly before the content item text. For example the 'Content - Rating' plugin.
  • onPrepareContent: Prepares a RAW content item ready for display. If you intend to modify the text of an item, you should use this event.

Probably the most complex of all the core plugins are editors. These plugins are used to render handy client-side textarea editors. One of the core editors is TinyMCE (http://tinymce.moxiecode.com/), a separate project in its own right. TinyMCE is a JavaScript-based editor, which allows a user to easily modify data in a textarea without the need for any knowledge of XHTML.

  • onDisplay: Gets the XHTML field element to use as the form field element.
  • onGetContent: Gets some JavaScript, which can be used to get the contents of the editor.
  • onGetContent: when the contents of the editor are requested
  • onGetInsertMethod: Gets some JavaScript which defines a function called jInsertEditorText().
  • onInit: Initialize the editor. This is only run once irrespective of how many times an editor is rendered.
  • onSave: Gets some JavaScript, which is used to save the contents of the editor.
  • onSetContent: Gets some JavaScript, which can be used to set the contents of the editor.

This group is used to extend editor plugins by creating additional buttons for the editors. Unfortunately, the core 'xstandard' editor does not support these plugins. There is only one event associated with this group, onCustomEditorButton.

  • onCustomEditorButton: Build a custom button for an editor.

We use search plugins to extend the core search component and get search results. There are two events associated with this group, onSearch and onSearchAreas. The purpose of onSearchAreas is a little more obscure.

  • onSearch: Perform a search and return the results.
  • onSearchAreas: Gets an array of different areas that can be searched using this plugin. Every search plugin should return at least one area.

System events occur every time a request is made.

  • onAfterDispatch: Occurs after the application has been dispatched.
  • onAfterInitialize: Occurs after the application has been initialized.
  • onAfterRender: Occurs after the application has been rendered, but before the response has been sent.
  • onAfterRoute: Occurs after the application has been routed.

User plugins allow additional processing during user-specific events. This is especially useful when used in conjunction with a component that defines tables that are associated to the core #__users table.

  • onBeforeStoreUser: Allows us to modify user data before we save it.
  • onAfterStoreUser: Allows us to execute code after a user's details have been updated. It's advisable to use this in preference to onBeforeStoreUser.
  • onBeforeDeleteUser: Enables us to perform additional processing before a user is deleted. This is useful for updating non-core tables that are related to the core #__users table
  • onAfterDeleteUser: Same as onBeforeDeleteUser, but occurs after a user has been removed from the #__users table.
  • onLoginFailure: During a failed login this handles an array derived from a JAuthenticationResponse object.
  • onLoginUser: During a successful login this handles an array derived from a JAuthenticationResponse object.
  • onLogoutUser: User is attempting to logout. The user plugin 'joomla' destroys the session at this point.

XML-RPC is a way in which systems can call procedures on remote systems via HTTP using XML to encode data. Joomla! includes an XML-RPC server, which we can extend using plugins.

There are essentially two parts to XML-RPC plugins: the event handler for the event onGetWebServices, which returns an array of supported web service calls, and a static class or selection of functions that handle remote procedure calls.

  • onAuthenticate: when a user initially attempts to authenticate, provides a method for authentication