In this chapter, Mark Dexter and Louis Landry examine how plugins work and the different types of events that can trigger plugins. They look at some core plugins and then create their own plugin, based on the user registration form they created previously.

This chapter is from the book

This chapter is from the book

Then we create a zip archive that allows any Joomla! website to install and use our plugin extension. Next we add some parameters to the plugin and discuss the JForm class that handles parameters. We add a language file to handle translating the text for our plugin.

Finally, we discuss some powerful things that plugins allow us to do, including overriding models, tables, and other standard Joomla classes. We finish by discussing some best practices for developing and using plugins.

What Is a Plugin?

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.

A plugin can be very simple—for example, to set a value before saving a field to the database. Or it can be very complex—for example, to convert all the URLs in a document to a different format. Plugins can even be used to override standard core classes.

Plugins are tied to events. To understand plugins, we need to understand the predefined events in Joomla and also how to create our own events.