Creating a Hello World Module for Joomla! 1.5
A module is a lightweight and flexible extension that is used for page rendering. They are used forsmall bits of the page that are generally less complex and are able to be seen across differentcomponents. You can see many examples of modules in the standard Joomla! install: - menus - Latest News -Login form - and many more. This tutorial will explain how to go about creating a simple Hello World module. Through this tutorialyou will learn the basic file structure of a module. This basic structure can then be expanded toproduce more elaborate modules.
There are four basic files that are used in the standard pattern of module development: *mod_helloworld.php - This file is the main entry point for the module. It will perform any necessaryinitialization routines, call helper routines to collect any necessary data, and include the templatewhich will display the module output.
mod_helloworld.xml - This file contains information about the module. It defines the filesthat need to be installed by the Joomla! installer and specifies configuration parameters forthe module.
helper.php - This file contains the helper class which is used to do the actual work inretrieving the information to be displayed in the module (usually from the database or someother source).
tmpl/default.php - This is the module template. This file will take the data collected bymod_helloworld.php and generate the HTML to be displayed on the page.
The mod_helloworld.php file will perform three tasks:
include the helper.php file which contains the class to be used to collect the necessary data
invoke the appropriate helper class method to retrieve the data
include the template to display the output. The helper class is defined in our helper.php file. This file is included with a require_once statement:
require_once( dirname(__FILE__).DS.'helper.php' );
require_once is used because our helper functions are defined within a class, and we only want theclass defined once.Our helper class has not been defined yet, but when it is, it will contain one method: getHello(). Forour basic example, it is not really necessary to do this - the “Hello, World” message that this