J1.5 talk

Difference between revisions of "Creating a simple module"

From Joomla! Documentation

m (Wilsonge moved page Talk:Creating a simple module to J1.5 talk:Creating a simple module: Move to 1.5 namespace)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
==Difficult==
 +
 +
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.
 
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.
  
Line 8: Line 14:
 
the PHP file starts like this:
 
the PHP file starts like this:
  
<code><?php
+
<source lang="php">
 +
<?php
 
/**
 
/**
 
* @version              $Id: modulename.php 10079 date time author $
 
* @version              $Id: modulename.php 10079 date time author $
Line 19: Line 26:
 
// 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 46: Line 53:
 
         </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.

Latest revision as of 15:31, 29 April 2013

Difficult[edit]

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[edit]

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.