Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 6th Jan 2012, 08:12 AM   #1
Warrior Member
 
Join Date: 2011
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
Lightbulb
How to Develop a Custom Joomla Module?
Share on: 
fb share twitter share gplus share more share

We have spoken and wrote about many articles on Joomla and its importance on website Development. Now for better understanding of Joomla, here we present an article on How to develop a custom Joomla Module. For better introduction, we can take an image slider module creation that we had developed as an example.
The basic form of Joomla 1.5 consist of two files:
XML file
PHP file
XML file has general information about the module as shown in administration Interface of Joomla module manager and also module parameters that helps to modify the appearance/functionality of the module. The PHP file affords controlling logic to the module as per our requirement.
The Basic files required to create a Joomla custom (Image Slider) module are given below
• index.html
• module_name.xml (Eg. mod_simpleslider.xml )
• module_name.php (Eg. mod_simpleslider.php)
Note: It is very important, that XML file name must matches module name. Otherwise, installer will install the module, but Joomla wouldn’t show parameters and additional information stored in XML.
Index file format:
index.html
This helps to ensure that a default page is displayed without listing all of the other files in the directory incase of unauthorized users attempted to access the directory. It’s not necessary, but a good practice.
<html><body background=”#fff”></body></html> XML file format:
mod_simpleslider.xml
<?xml version=”1.0″ encoding=”utf-8″?>
<install type=”module” version=”1.5.0″>
// Name of the Module
<name>SimpleSlider Module</name>
// Name of the Author
<author>treeshoredotcom</author>
//Version Month & year of the Module
<creationDate>December 2011</creationDate>
//Copyright information
<copyright>All rights reserved to TreeShoredotcom.</copyright>
//License Information
<license>GPL 2.0</license>
//Author’s email address
<authorEmail>contactattreeshoredotcom</authorEmail>
// Author’s website
<authorUrl>TreeShore - Ecommerce Web Design Company | Web Development Company | Custom Software Development | Internet Marketing</authorUrl>
//Module version number
<version>1.0.0</version>
//Description of what the module does
<description>SimpleSlider – This module will show image slideshow created with Simpleslider</description>
// Listing of all files that should be installed for the module to function – in our case the file structure will be…
<files>
<filename module=”mod_simpleslider”>mod_simpleslider.php </filename>
<filename>index.html</filename>
<folder>tmpl/</folder>
<folder>engine/</folder>
<folder>data/</folder>
</files>
//Optional parameters
<params>
</params>
//in our case
<params group=”advanced”>
<param name=”cache” type=”list” default=”1″ label=”Caching” description=”Select whether to cache the content of this module”>
<option value=”1″>Use global</option>
<option value=”0″>No caching</option>
</param>
<param name=”cache_time” type=”text” default=”900″ label=”Cache Time” description=”The time before the module is recached” />
</params>
</install> The Installer copy and install the files as defined by the above xml file. Notice that we DO NOT include a reference in the files section for the XML file.
PHP File Format
mod_simpleslider.php:
The basic structure of a module PHP file format will be looks like the following:
<?php //don’t allow other scripts to grab and execute our file
defined(‘_JEXEC’) or die(‘Direct Access to this location is not allowed.’);
?>

In our case: the php file will be:-
<?phpaddStyleSheet(JURI::base() . ‘modules/mod_’.$module->name.’/engine/style.css’);
//by default to retrieve a style sheet, the format will be
//$document->addStyleSheet(JURI::base() . ‘modules/mod_’.$module->name.’$your url to stylsheet directory’);

$document->addScript(JURI::base() . ‘modules/mod_’.$module->name.’/engine/jquery.js’);
//by default to retrieve a js file, the format will be
//$document->addScript(JURI::base() . ‘modules/mod_’.$module->name.’$your javascript/jquery directoy url’);
$document->addScript(JURI::base() . ‘modules/mod_’.$module->name.’/engine/wowslider.js’);
require(JModuleHelper::getLayoutPath(‘mod_’.$m odule->name));
?>
When the above mod_simpleslider.php file is loaded in Joomla by means of PHP include directive it retrieves the stylesheet & javascript files from its source directory and produces the slider output to the final page.
To package this module for distribution and installation, simply zip the files together: Eg. mod_simpleslider.zip.
The resulting mod_simpleslider.zip file may be uploaded and installed through the standard Joomla! 1.5 Extension Manager.

vijaykumarg is offline  
The Following User Says Thank You to vijaykumarg For This Useful Post:
Unread 6th Jan 2012, 12:28 PM   #2
Active Warrior
 
masterxm's Avatar
 
Join Date: 2009
Location: Arround the World!
Posts: 58
Thanks: 0
Thanked 3 Times in 3 Posts
Default
Re: How to Develop a Custom Joomla Module?
Share on: 
fb share twitter share gplus share more share

what is joomla ?


masterxm is offline  
Unread 6th Jan 2012, 11:44 PM   #3
Warrior Member
 
Join Date: 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: How to Develop a Custom Joomla Module?
Share on: 
fb share twitter share gplus share more share

This is also too complicated
telofint is offline  
Unread 7th Jan 2012, 02:49 AM   #4
Warrior Member
 
Join Date: 2012
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: How to Develop a Custom Joomla Module?
Share on: 
fb share twitter share gplus share more share

I really like your provided information. It's really helpful. But it's difficult for beginner.

evantanski is offline  
Unread 3rd Apr 2012, 03:30 AM   #5
Warrior Member
 
indiawebdevelop's Avatar
 
Join Date: 2012
Location: India
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: How to Develop a Custom Joomla Module?
Share on: 
fb share twitter share gplus share more share

Yes its fact that develop a custom Joomla module is little difficult for a newbie of Joomla. But if you have few php and scripting language knowledge, you can learn fast.

indiawebdevelop is offline  
Unread 3rd Apr 2012, 06:23 AM   #6
HyperActive Warrior
War Room Member
 
Earnie Boyd's Avatar
 
Join Date: 2012
Posts: 290
Thanks: 13
Thanked 46 Times in 46 Posts
Default
Re: How to Develop a Custom Joomla Module?
Share on: 
fb share twitter share gplus share more share

Cool, Drupal does pretty much the same thing but instead of .xml it uses a simple text .info which is easier to produce with a simple text editor. I'm happy you shared your experience, I'm trying to learn more than one CMS.

Earnie Boyd is offline  
Closed Thread


Bookmarks

Tags
custom, develop, joomla, module


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 04:05 PM.