Donate

If any of the tips on this site have helped you out, consider buying me a cup of coffee. -dcPages
Joomla! Plugin Tutorial PDF Print E-mail
Written by dcPages   
Article Index
Joomla! Plugin Tutorial
Joomla! Plugin Tutorial - Page 2
Joomla! Plugin Tutorial - Page 3
Joomla! Plugin Tutorial - Page 4
All Pages

This article is designed to help budding Joomla! developers who want to learn how to write a plugin for Joomla! 1.5. The wonderful thing about an open source CMS (like Joomla!) is the extensibility. I often have clients who want to know if their website can do something, and with an open source CMS, the answer is always yes (it's then just a matter of whether you can afford to get it done). In Joomla! there are several types of extensions - modules, plugins and components. This article will focus on creating a plugin. Let's dive in!

To begin, it's important to understand what a plugin is (and what it isn't). Basically, a plugin is a snippet of code that modifies the output of the site. It can be used to change the text on the screen, to highlight certain elements, to automatically change URLs into HTML links, to make email addresses into MAILTO: links, etc. (You could even use a plugin to insert a block of text, but this is typically better served by a module - unless you need that block of text to go somewhere a module can't or place that text within another module).

Plugins consist of (at least) two files:

  • [pluginname].php - this file does the work, it holds the php code that will actually do something to your site
  • [pluginname].xml - this is a basic xml file that contains the details of your plugin, e.g. name, version, licensce, more importantly, it contains a list of the file(s) contained in your plugin, so Joomla! can install them, and the parameters you want your users to be able to adjust.

The basic functioning of a plugin goes something like this:

  1. User installs plugin (using the package you have created, typically called [pluginname].zip)
  2. User configures plugin by setting values for the parameters you defined in your XML file
  3. Website loads a page or runs a piece of code that fires an event that your plugin registered for (in the PHP file)
  4. Your plugin runs, grabs the parameter values that the user entered, and returns an output

That's basically it, but to go a little deeper, let's create a plugin from scratch. For the purposes of this tutorial, we'll walk through how to create the dcGoogleAnalytics plugin.

Click to the next page to begin.



 
 

Search

Polls

How Many Phone Numbers Should dcRedial Show?