Modules are extensions that you can be add into your Joomla website to display information or perform a task, some examples are the login form, or even my Services Section, were on the back end I have a form to introduce all my services into a database table and my module is in charge of displaying this information, making the update of my services extremely easy.

This article will teach you to create a module for Joomla 2.5, hoping that you can modify it to make it work as your needs.

 First of all, you will need to have at least 3 files inside a folder with name mod_"my_module_name", the files are:

  • index.html: this is could be just a blank file, it is recommended for security reasons to have 1 in each joomla folder.
  • mod_"my_module_name".xml: we will see this file in details below, but as a summary this files contains and define the information that the module will need in order to work, install properly.
  • mod_"my_module_name".php: is the file that contains the orders of "what to do" in your module.
  • mod_"my_module_name".css: (optional) if you want to add some styling into your module.

 Lets start with the simple one, index.html:


For the xml file I consider this divided in three main parts, top part: introduction, middle part: where are my files, and finally parameters, this is could be the hardest part, because from here, after the module is installed you can modify the way the module work.

<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="1.7.0" client="site" method="install">
  <name>Name the way it will appears in the module manager</name>
  <author>Autor name</author>
    <filename module="mod_name">mod_name.php</filename>
    <fields name="params" addfieldpath="modules/mod_name/folder_name"><!-- This allows me to add custom field into the parameters 
      <fieldset name="basic">
        <field name="title" type="database" default=" " label="Select table" description="Select table to display information" />

        <field name="layout" type="list" default="default" label="Layout" description="Layout to use for displaying the list">
          <option value="default">Plain List</option>
          <option value="ordered">Ordered List</option>
          <option value="paragraphs">Paragraphs</option>


Everything from the first line until description. It is actually very straight forward.

Middle part:

This is were you have to define all the files inside you module folder, you have to be very careful here, if you misspell or miss a file, folder, sometimes the module will install or will not. If install, it will not run as expected on the other hand, joomla will give you a message describing what was missing to declare.

Botton part:

I will leave this for a new tutorial. The parameters could be as simple as the introduction part or it could be very complex (if you are building your own parameters). In this tutorial we are creating a simple module so we will omit this information.


The purpose of this module will be to display which modules are published currently  in your Joomla website.

defined( '_JEXEC' ) or die;
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$rows = $db->loadObjectList();
echo "<div id='test_mod'><ol>";
foreach ( $rows as $row ) {
echo "<li>$row->title</li>";
echo "</ol></div>";

as a result you will end up having something like this:

Just remember to add a position ("it can be: testmodule"), published, and do the menu assigment in order to display it

{"loadposition testmodule"} (without the "")

{phocadownload view=file|id=6|text=Module Tutorial|target=s}