Tuesday, October 6, 2009

How to make your own module in joomla

First you must create an xml file for your script.
This xml file tells joomla what is that file for either a plugin, component,
or module.

This what your xml file looks like.

Save this file as mod_sample_module.xml

file: mod_sample_module.xml

<?xml version="1.0" encoding="utf-8"?>

<install type="module" version="1.5.0">
<name>sample module</name>

<author>author name</author>

<creationDate>Aug 2009</creationDate>

<copyright>(C) 2009 alreymark.blogspot.com</copyright>

<authorEmail>test@alreymark.blogspot.com</authorEmail>

<authorUrl>http://alreymark.blogspot.com</authorUrl>

<version>7.0.7</version>

<description>alreymark</description>

<files>

<filename module="mod_sample_module">mod_sample_module.php</filename>

</files>

lt;/install>


As you seen in the xml file, there are fields that are set for the user to
fill up and the most special field of the xml file is the <files> and <filename> tag.
This will tell joomla what you are creating and what is the type of the file
wether a module, plugin, or a component. Make sure what is in between of the
<filename> tag is the filename of your php script that we will create after
this.


file: mod_sample_module.php


<?php
echo "joomla module test";
// your other code here.
?>


After creating the two important files(php file and xml file), you must
compressed it using zip. Name the zip file as long as you like.

After you have compressed the two files and make it one zip file.
Install it in joomla admin using standard installation.
Extensions >> Install/Uninstall.
Now your own module is now installed. You can see your installed
module in Extensions >> Module Manager.

How does it work?
1. First go to module manager and find the module that you have recently
installed. (The module that you make)
2. When you are in the module, try to change the position. Name it as
what you like.
In here i will name it as "sample_module".(position: sample_module)

3. Then create an article. In the text editor, right this joomla script:

{loadposition sample_module}

syntax:
{loadposition module-position-name}


4. Saved the article. And in your homepage, visit the article that
you have recently added. It should show "joomla module test".

Now you have your own module. You can modify the php script as what you like.
Access it in module directory of your joomla site using ftp or others.

Hope it help!:)

No comments: