Actions

J1.5 talk

Difference between revisions of "Creating a simple module"

From Joomla! Documentation

m (Replaced <code> tags with applicable <source> tags)
Line 8: Line 8:
 
the PHP file starts like this:
 
the PHP file starts like this:
  
<code>
+
<source lang="php">
 
<?php
 
<?php
 
/**
 
/**
Line 20: Line 20:
 
// no direct access
 
// no direct access
 
defined('_JEXEC') or die('Restricted access');
 
defined('_JEXEC') or die('Restricted access');
</code>
+
</source>
  
 
Then lays out the code for whatever the module is trying to do.
 
Then lays out the code for whatever the module is trying to do.
  
 
The XML file follows the following format:
 
The XML file follows the following format:
<code>
+
<source lang="xml">
 
<?xml version="1.0" encoding="utf-8"?>
 
<?xml version="1.0" encoding="utf-8"?>
 
<install type="module" version="1.5.0">
 
<install type="module" version="1.5.0">
Line 47: Line 47:
 
         </params>
 
         </params>
 
</install>
 
</install>
</code>
+
</source>
  
 
The params section is optional.
 
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.
 
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.

Revision as of 08:53, 17 December 2008

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:

<?php
/**
* @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">
        <name>Modulename</name>
        <author>Your Name</author>
        <creationDate>Date</creationDate>
        <copyright>Copyright (C) whoever. All rights reserved.</copyright>
        <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
        <authorEmail>your@email.address</authorEmail>
        <authorUrl>your.website.address</authorUrl>
        <version>1.5.0</version>
        <description>This module does whatever function you describe here</description>
        <files>
                <filename module="modulename">modulename.php</filename>
        </files>
        <params>
                <param name="something" type="whatever" >
                        <option value="1">option 1</option>
                        <option value="0">option 2</option>
                </param>
        </params>
</install>

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.