Rvsjoen/tutorial/Developing a Module/Part 01

From Joomla! Documentation

< User:Rvsjoen‎ | tutorial/Developing a Module

Developing a Basic Module

Let's create a Hello World! module. All file name and path references in this tutorial are relative to the directory you are developing your extension in. In order to create a very basic module, all that is really needed is two files. A module file and an XML manifest. This module will do nothing more than to spit out the words "Hello World!" into the position in which it is published.

With your favorite editor, create the following file


Hello World!

With your favorite editor, create the following file


<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="2.5.0" method="upgrade">

        <name>Hello World!</name>
        <!-- The following elements are optional and free of formatting constraints -->
        <creationDate>Once upon a time</creationDate>
        <author>John Doe</author>
        <copyright>Copyright Info</copyright>
        <license>License Info</license>
        <!--  The version string is stored in the extension table -->
        <!-- The description is optional and defaults to the name -->
        <description>Description of the Hello World module ...</description>

        <!-- Note the folder attribute: This attribute describes what to copy
                into the module folder -->
                <filename module="mod_helloworld">mod_helloworld.php</filename>


As we can see, there is a lot of markup here. This is pretty much a minimal extension manifest and we will try to explain the most important bits and pieces. The important thing to note here is the module="mod_helloworld" attribute which specifies which file is considered the entry point for the module. In theory this can be any file you want but to follow proper naming conventions we name this file mod_helloworld.php.

Installation and Testing

Before testing your shiny new module you have to install it. In Joomla! there are two ways of doing that, either by packaging the extension into an installable zip package or by using the discovery method. Both methods are described below but I recommend using the packaged zip file as a beginner because it is more hostile towards errors especially in the XML manifest.

Installing your module

If you have used Joomla before reading this tutorial, you have noticed that extensions are installed using a compressed file containing all the things which are needed for installing and uninstalling them.

A new feature made available in Joomla! 1.6 is "discover." That means you can place the files in the correct places inside your Joomla! installation (The proper file path for this module will be in modules/mod_helloworld within the Joomla! root), and the "Discover" option within the extension manager will install it, when selected.

Packaging an installation zip file

Create a compressed file of your extension directory using the structure shown in the file listing section of this page or download the provided installable package.

When you have this package, install it using the extension manager.

Testing your module

If you want to test this module, you first need to do a couple of things.

  1. Go to the Module Manager and edit the module
  2. Assign the module to a module position
  3. Make sure the module is published
  4. Make sure the module is assigned to show on some pages in the module assignment dialog

After performing these steps and saving the module you can navigate to the frontend and view the module.

File listing

Download this part

Download example package

Articles in this series

This tutorial is supported by the following versions of Joomla!

Joomla 2.5