Joomla plugin best practices

This excerpt is from the book, Joomla! Programming by Mark Dexter and Louis Landry, published by Pearson/Addison-Wesley Professional, April 2012, ISBN 013278081X, Copyright 2012. For further publisher info,

ITworld has 5 copies of Joomla! Programming to give to some lucky readers. Complete the form below for your chance to win!

The most important thing about plugins is to know when to use them. That means understanding the events available in Joomla and what standard behaviors you can override. In many cases, when you are having a difficult time figuring out how to solve a problem with a module or a component, a plugin might make the job a lot easier.

Here are some other tips about plugins:

  • Plugins are executed in the order in which they appear in the Ordering column in Plugin Manager. In most cases, the ordering doesn't matter. However, in some cases, where you have more than one plugin triggered from the same event, and where the results of one plugin can affect the processing of a subsequent one, the order can be important. In this case, you can change the order in the Plugin Manager by adjusting the Ordering values to control the execution order.

  • Normally, we want to use the naming conventions for plugin class names and method names. Otherwise, the plugins won't get called correctly. The exception is if you want the script to be run when the plugin is imported, in which case only the file and folder name is important (as in the class override example in the previous section).

  • Different events require different method signatures. Make sure you are aware of what values are available for each event and what values, if any, your method should return. The Joomla repository includes a folder called tests/plugins. This folder contains example plugins for each plugin type. These example files show all the events and the method signatures for each. Also, the plugin events are documented in the Joomla wiki at

  • Try to pick the best event for the job at hand. If you need a new event -- for example, in a custom component -- you can create it just by triggering it at the desired place in the program. If you believe that you need a new event added in a core class, ask about it on one of the development lists. If others agree, the event can be added to the core.

Enter now to win a copy of Joomla! Programming

First name: 
Last name: 
Enter me in the drawing to win a copy of "Joomla! Programming" Yes, I'd like to receive ITworld's daily newsletter Yes, I'd like to receive ITworld's open source newsletter

* All fields are required

By clicking submit you agree to the terms and conditions outlined in ITworld's privacy policy.
Read the official giveaway rules.

ITWorld DealPost: The best in tech deals and discounts.
Shop Tech Products at Amazon