Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create custom module in joomla

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 121
    Comment on it

    A module is light weight extension which pulls information from database or from joomla components.It can be placed in any predefined module position within joomla template. For Creating any custom module we need to create four basic files which are given below.Let say i want to create my custom module name as mytest. Need to create php file with mod as a prefix before module file name. mod_mytest.php : It is the main entry point of module.It calls helper routines to collect necessary data and include the template which display the output.

    <?php
    require 'helper.php';
    
    $test = modMyTestHelper::getTest($params);
    require JModuleHelper::getLayoutPath('mod_mytest');
    

    Next is to create an XML file with mod as prefix. mod_mytest.xml : this file defines information about the module.It includes the configuration parameters and defines file that need to be installed by joomla installer.

    <?xml version="1.0" encoding="utf-8"?>
    <extension type="module" version="3.1.0" client="site" method="upgrade">
        <name>custom module!</name>
        <author>kshitiz</author>
        <version>1.0.0</version>
        <description>A simple custom module.</description>
        <files>
            <filename>mod_mytest.xml</filename>
            <filename module="mod_mytest">mod_mytest.php</filename>
            <filename>index.html</filename>
            <filename>helper.php</filename>
            <filename>tmpl/default.php</filename>
            <filename>tmpl/index.html</filename>
        </files>
        <config>
        </config>
    </extension>
    

    helper.php : It is class which retrieves information usually from database or from some other source to be displayed on module.

    <?php
    
    class ModMyTestHelper
    {
        public static function getTest($params)
        {
            return 'Custom Module works fine!';
        }
    }
    

    tmp/default.php : It is a template file which retrieves the data from mod_mytest.php and generate the HTML on the page.

    <?php echo $test; ?>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: