Modules are the powerful way to add new functionality in a Joomla site. If you know how to write a Joomla module, you can convert any PHP code into Joomla Module for example a Jquery slideshow, facebook fanbox etc. Is it possible? Yes Ofcource it is! Modules are used to display data in all or few pages(you can choose menus from module settings).

Nothing is more easier than writing a Joomla Module. So what you are waiting for? Just go through the steps below and write your own module :)

Step 1. Create a new XML file and write these lines in the file( you can use any text editor but dreamweaver is recommended ).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="module">
<name>this is testing module</name>
<author>Ankur Sharma</author>
<creationDate>16/08/2010</creationDate>
<copyright>Wamptech</copyright>
<authorEmail>ankursharma@wamptech.com</authorEmail>
<authorUrl>www.ankursharma.net</authorUrl>
<version>1.0</version>
<description>module description here---- </description>
<files>
<filename module="mod_test">mod_test.php</filename>
</files>
<params>
<param name="test_title" type="spacer" default="===please enter Options ===" label="" description="" />
<param name="test_opt1" type="text" default="xyz" label="Option 1" description="option 1 for testing" />
<param name="test_opt2" type="text" default="abc" label="Option 2" description=" option 2 for testing" />
</params>
</install>

Step 2. Write the module name in between <name>…</name>

and similarly change author, creation date, copyright, author email,author url, version and description.

Step 3. In between the <filename></filename> write a php file name and create a new php file with the same name.

Step 4. Use the following code for its functional part:-

1
2
3
4
5
6
7
8
9
10
11
12
<?php
 
/// no direct access
defined('_JEXEC') or die('Restricted access');
 
$opt1 = $params->get('test_opt1','default value');  // get the parameters of the module
echo "the value of option 1 is:- ";
echo $opt1;
 
//Here you can print anything you want to print in the module 
 
?>

Here we are done.
Now, Zip both the files in one and install it by using the Joomla installer.

One Response so far.

  1. Mattingly says:

    You’re a real deep thinker. Thanks for sharing.