The basics of module development:
- The basic module consists of one folder and two files. In this example, the module will be named "My First Module":
Folder: mod_myfirstmodule
PHP File: mod_ myfirstmodule.php
XML File: mod_ myfirstmodule.xml
- The xml file is the user interface to the module, and contains the name and description, and any parameters the module gets from user input.
- The minimum code for the XML file is:
Code:
Screenshot:
- Additional recommended tags for the XML file:
• author
• creationDate
• copyright
• license
• authorEmail
• authorURL
• version
• description
• params
• module class suffix
The module class suffix is usually added to a module to allow template class styles to be applied to the module. Most commercial templates have a variety of module styles.
Code:
Screenshot:
- The PHP file requires minimum code as shown below. This code ensures that the script will only be executed by Joomla and prevents someone from accessing the file directly through the web browser.
Code:
Screenshot:
- For our first example, we will output a simple line of html code:
Code:
Screenshot:
- Publish the module to your website as you normally would (see Publish a Module to Your Website). View the module on your website.
- Next exercise: Get user input and display it in the module.
- In the XML file, add the following greeting text input within the params tag (see yellow highlighted code below):
Code:
Screenshot:
- In the PHP file, get the greeting text that was saved from the user input and save into a php variable (see yellow highlighted code below):
Code:
Screenshot:
- Display the variable in the html (see yellow highlighted code below):
Code:
Screenshot:
- Test the module: Open the module in the Module Manager, type "Welcome" in the Greeting input box, save, view on the website.
- In the XML file, add the following greeting text input within the params tag (see yellow highlighted code below):
Watch the Videos:
(This tutorial has a 3-part video)
Rating: 2.7 (342 Votes)
Rating: 2.6 (328 Votes)
Rating: 2.8 (304 Votes)
iPhone Videos:







teto makes this comment
Tuesday, 01 December 2009
Far East makes this comment
Sunday, 03 January 2010