Creating modules for Joomla 1.0.x

07 May 2009 Published in Blog

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

    Hola Mundo
    Juan
    11/12/2008
    (C) 2008 Serfe. All rights reserved.
    https://www.gnu.org/copyleft/gpl.html GNU/GPL
     info@serfe.com
    https://www.serfe.com
    0.0.1
    Este modulo pretende explicar el funcionamiento de los módulos en Joomla.
    
        mod_hmundo.php
    
    
      
        
        
        
      
    

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
get( 'parameterexample', 0 );
 
echo "Hello world!
"; echo "You choose the parameter: $param";   ?>

This is our module. As you can see it is as simple as that. We have a line that prints the traditional “Hello World” and then a text indicating that the parameter is set in the administration.

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.

Serfe info(at)serfe.com https://www.serfe.com/images/serfe_logo_text.png https://www.serfe.com/images/serfe_logo_text.png FALUCHO 2032, S3016LDB, SANTO TOME, SANTA FE, ARGENTINA 1-305-5375397
Cookies & Privacy: 
This website uses cookies to ensure you get the best experience on our website.


Privacy Policy