J1.5 talk

Creating a simple module

From Joomla! Documentation

Revision as of 14:31, 29 April 2013 by Wilsonge (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


It'd be nice if someone could modify this page and add explanations of some of the code. Most of the time the author assumes you should just work it out or something, not very helpful. For instance, what is jtext, what is JModuleHelper::getLayoutPath? There is basically two lines for each block of code at the moment.

Other guy

Uh...ok, wow. I don't dare try to modify the main page as I'm absolutely a greenhorn at Joomla, but as I'm absolutely needing to know this information like right now, I'll at least add comments here to help the next guy out.

So, to get started, you can look at the previous version of Joomla to get the ball rolling. A link can be found here: Module Creating a simple module

Basically, things have changed a bit since that version, so you need to create two files modulename.php and modulename.xml

the PHP file starts like this:

* @version              $Id: modulename.php 10079 date time author $
* @package              Joomla
* @copyright    Copyright (C) whoever. All rights reserved.
* @license              GNU/GPL, see LICENSE.php
* See COPYRIGHT.php for copyright notices and details.
// no direct access
defined('_JEXEC') or die('Restricted access');

Then lays out the code for whatever the module is trying to do.

The XML file follows the following format:

<?xml version="1.0" encoding="utf-8"?>
<install type="module" version="1.5.0">
        <author>Your Name</author>
        <copyright>Copyright (C) whoever. All rights reserved.</copyright>
        <license> GNU/GPL</license>
        <description>This module does whatever function you describe here</description>
                <filename module="modulename">modulename.php</filename>
                <param name="something" type="whatever" >
                        <option value="1">option 1</option>
                        <option value="0">option 2</option>

The params section is optional.

Once these files are created, you have to place them where either your web browser or your server can get to them, and then use the Joomla Administrator panel to install the module. This creates the necessary database rows to serve the module where you need it to function.