Joomla Module Development Part I

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 a 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 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 all your project requirements. Joomla development skills comes very handy in situations like this.

Best Joomla Module Development

Best Joomla Module Development

Developing a Simple Joomla Module Development

Lets 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 name helloworld, we will create a folder named mod_helloworld in 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. Name of these two files must be same as the name of our module so two files created will be mod_helloworld.php and mod_helloworld.xml.

What will go inside these two files?

Lets open our favorite text editor (I am fan of adobe dreamweaver) and create a new file xml file and save it the folder you created in starting and name of the file must be mod_helloworld.xml.

Lets understand each line of code one by one:

First line says about the xml version and its character set. Actual code of our module starts with the tag and attributes of this tag defines the type of extension, version of joomla and client. In our case type is module as we are developing a joomla module, that changes to component if we are developing a component or to 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. Client tells the area for which we are developing the module. Site means we are developing it for site part, other possible value can be admin if we want to develop a module for joomla admin section.

here is the explanation for each tag inside extension tag

<name> tag contains the name of your module that is mod_helloworld in our case. change if you are developing it with your own name.
<author> tells the name of 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 about what your module do.

Next important tag is files. It tells joomla what are the files to upload while installing your module from admin section. Each file is specified individually with a filename tag inside files 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 lets move on to the 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 php tag itself. Second is most important one and goes in every php file of weather 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 prevent direct access to in web browser address bar.

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 exercise and post any question comment below. In the next tutorial we will learn how to add module parameters and use that in frontend.

Leave a Reply

Your email address will not be published.


Leave a Reply

Your email address will not be published.