Joomla Module Development Part I

by Comments closed In: Development, Joomla

Joomla Module Development – This article is to teach you how to develop your own custom module around Joomla CMS. This course will start with simple Joomla module development and will move on to teaching extensive Joomla module development.

Joomla is the most widely used and popular content management system. If you are a professional or freelance website developer, many times your client might ask you to develop a website with Joomla or you may propose a certain website to be developed with Joomla. Joomla comes with lots of features buts its not possible for a CMS to cater to all your project requirements. Joomla development skills come in very handy in situations like this.

Best Joomla Module Development

Best Joomla Module Development

Developing a Simple Joomla Module Development

Let’s start with a hello world kind of module with Joomla. First of all, we need to create a folder for our module that will have a name starting with mod_ followed by name of your module. so if we want to create a module having the name helloworld, we will create a folder named mod_helloworld on our computer.

Inside that mod_helloworld folder, we will create two files (only two files are required for a basic module). One XML file that will tell Joomla about our module and one PHP file to perform our intended task for the module. The name of these two files must be the same as the name of our module so the two files created will be mod_helloworld.php and mod_helloworld.xml.

What will go inside these two files?

Let’s open our favorite text editor (I am a fan of adobe DreamWeaver) and create a new file XML file and save it to the folder you created in starting and name of the file must be mod_helloworld.xml.

Let’s understand each line of code one by one:

The first line says about the XML version and its character set. The actual code of our module starts with the tag and the attributes of this tag define the type of extension, version of Joomla, and client. In our case type is a module as we are developing a Joomla module, that changes to a component if we are developing a component or to a plugin, if we are developing a Joomla plugin.

Version is the version of Joomla for which we are developing our module. 1.6.0 works in all versions of Joomla 1.7 and Joomla 2.5. A client tells the area for which we are developing the module. Site means we are developing it for the site part, other possible value can be admin if we want to develop a module for the Joomla admin section.

here is the explanation for each tag inside the extension tag

<name> tag contains the name of your module which is mod_helloworld in our case. change if you are developing it with your own name.
<author> tells the name of the author of the module. change it with your name
<creationDate> of the the module
<copyrights> name of the party, individual having copyrights of this module
<license> license text of the module
<authorEmail> email id of the author
<authorUrl> URL of author’s website
<version> version of your module
<description> description of what your module does.

The next important tag files. It tells Joomla what files to upload while installing your module from the admin section. Each file is specified individually with a filename tag inside the file tag. One important thing to note here is module=”mod_helloworld” in first <filename> tag. It should be always the name of your module.

At the end of this file, we close the extension tag. Now let’s move on to another file of our module that is mod_helloworld.php. This file is actually responsible for printing the output of our module.

Just three lines of code and out of that the first one is the start of the PHP tag itself. The second is the most important one and goes in every PHP file whether we are developing a module, component, plugin, or template. We use this line to prevent direct access to our code, that means if our website is this line of code prevents direct access to in the web browser address bar.

The next line is a simple PHP echo statement, announcing your first Joomla module! We can output whatever we want here.

Download the zip file of the exercise and post any question comments below. In the next tutorial, we will learn how to add module parameters and use that in frontend.