Creating modules for Joomla 1.0.x
What is a module?
Modules are small programs that can be inserted anywhere in a site that uses Joomla.
Depending on the template (the part that handles the entire display) can be placed anywhere dynamically configuring it on the backend.
The function of the modules is basically display information in a small box, for example, could be used to show user data, date and time, temperature of a place in particular, etc. You can also use a module to link it to component and use it as a submenu.
Needed Files
You need 2 files to create a module: One is the XML file that is used for installing and configuring the module in Joomla. The other is the PHP file itself, which perform the task of displaying data on the site. Is necessary to respect the nomenclature putting “mod_” to the name of the module. This is important in order to install it on the Joomla´s backend.
Example of module: Hello World!
XML: mod_hworld.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?xml version="1.0" encoding="iso-8859-1"?> <mosinstall type="module" version="1.0.0"> <name>Hola Mundo</name> <author>Juan</author> <creationDate>11/12/2008</creationDate> <copyright>(C) 2008 Serfe. All rights reserved.</copyright> <license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license> <authorEmail> info@serfe.com</authorEmail> <authorUrl>http://www.serfe.com</authorUrl> <version>0.0.1</version> <description>Este modulo pretende explicar el funcionamiento de los módulos en Joomla.</description> <files> <filename module="mod_hmundo">mod_hmundo.php</filename> </files> <params> <param name="ejemploparametro" type="radio" default="0" label="Ejemplo de Parametros" description="Mi descripcion"> <option value="0">Parametro 0</option> <option value="1">Parametro 1</option> <option value="2">Parametro 2</option> </param> </params> </mosinstall> |
In this file we are going to put all the information about the module: the author, date and characteristics of the module. There are 2 important tags:
File Tag: we need to identify the files included in this module. In our example we only have a single file called mod_hworld.php.
Params Tag: are set the module parameters that can be changed from the administration. In this case we will test 3 parameters to learn how to use them.
PHP: mod_hworld.php
1 2 3 4 5 6 7 8 9 10 11 | <?php // no direct access defined( '_VALID_MOS' ) or die( 'Restricted access' ); $param = $params->get( 'parameterexample', 0 ); echo "Hello world!<br>"; echo "You choose the parameter: $param"; ?> |
Finaly, we compress and install:
Once we have these 2 files, we compresses it into one .zip or .tar, we go to our Joomla administrator and install it like any module. If the xml is correct, this will add the module to the database and will be availible in the module section to be used.
Tags: Joomla, Joomla Extension, Modules
















