The overview:
You create a zip file that you can use to do an install using Mambo
installer What is needed:
mod_yourmodule.php and mod_yourmodule.xml. Use these two
files to create mod_yourmodule.zip What is mod_yourmodule.xml:
This is a file that the installer need to know some info regarding your
module and do the install What is mod_yourmodule.php:
This is a file where you put the logic of your module to be executed by Mambo
Here is a sample content would go in your mod_yourmodule.xml <?xml version="1.0" ?>
<mosinstall type="module">
<name>YourModuleName</name>
<creationDate>mm/dd/yyyy</creationDate>
<author>Your Name</author>
<copyright>This module is released under the GNU/GPL License</copyright>
<authorEmail>
</authorEmail>
<authorUrl>http://www.yoursite.com</authorUrl>
<version>1.0</version>
<description>Some description of your module</description>
<files>
<filename module="mod_yourmodule">mod_yourmodule.php</filename>
</files>
<params>
</params>
</mosinstall>
Here is a more expanded info on params <params>
<param name="ButtonName" type="radio" default="1" label="A button" description="Display radio button">
<option value="0">option1</option>
<option value="1">option2</option>
</param>
<param name="items" type="text" default="0" label="How Many?" description="Display text" />
<param name="style" type="list" default="" label="Style" description="Display a list">
<option value="one">One</option>
<option value="two">Two</option>
</param>
</params>
Note: There are more type available but I don't have them all here you will need to hack the code to find out more or when I do I will update this article later.
Here is a content would go in your mod_yourmodule.php
Let say you want to get some data from your database and I
just use my comments table as an example here. This is very simple version of a module like a "hello world" type you can expand on this to utilize the parameters as described above to add more customization to your module or add more data validation routine. It is only limit to your imagination! <? // beginning of module
// must have to protect from potential security risk
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
// declare your database
global $database;
// get the latest 5 comments
$qry="SELECT * FROM #__content_comments WHERE published = '1' ORDER BY id DESC LIMIT 5";
$database->setQuery($qry);
// get and load the records from the query
$rows = $database->loadObjectList();
// process each row, build and print the URL of the comment
foreach($rows as $row) {
$thisurl="index.php?option=com_content&task=view&id=".$row->articleid."&Itemid=1&show=1";
echo "<a href=\"$thisurl#comments\">".substr($row->entry,0,20)."...</a><br>";
}
// end of module
?>