Professional Documents
Culture Documents
5 Modules
What can you do with them?
What not?
How to module DIY?
C Show results
<params>
<param name="count" type="text" default="5" label="Number
of weblinks" description="The number of weblinks to display
(default is 5)" />
</params>
It is working!...
</params>
Storage in jos_modules
Model-View-Controller (MVC)
class modDB8LatestWeblinksHelper
{
// [retrieve parameters]
// [return data]
}
class modDB8LatestWeblinksHelper
{
function &getItems(&$params){
// [retrieve parameters]
$count = intval($params->get('count', 5));
class modDB8LatestWeblinksHelper
{
function &getItems(&$params){
// [retrieve parameters]
// [retrieve database records]
$db =& JFactory::getDBO();
$query = 'SELECT title, url, description' .
' FROM #__weblinks' .
' ORDER BY date DESC';
$db->setQuery($query,0,$count);
$list = $db->loadObjectList();
Peter Martin – joomladays.nl – 13 June 2009 38
Module - MVC style: 2. helper file
helper.php - shown in 3 parts: 3rd part
class modDB8LatestWeblinksHelper
{
function &getItems(&$params){
// [retrieve parameters]
// [return data]
return $list;
}
}
Peter Martin – joomladays.nl – 13 June 2009 39
Module - MVC style: 3. installer file
mod_db8latestweblinks.xml
<?xml version="1.0" encoding="utf-8"?>
<install type="module" version="2.1" client="site">
<name>db8 Latest Weblinks</name>
<author>Peter Martin (pe7er)</author>
<authorEmail>joomla@db8.nl</authorEmail>
<authorUrl>www.db8.nl</authorUrl>
<creationDate>June 2009</creationDate>
<copyright>Copyright 2009 by Peter Martin / db8.nl.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<version>2.3</version>
<description>This module shows the latest weblinks.</description>
<files>
<filename module="mod_db8latestweblinks">mod_db8latestweblinks.php</filename>
</files>
</install>
<params>
<param name="moduleclass_sfx" type="text" default="" label="Module Class Suffix"
description="PARAMMODULECLASSSUFFIX" />
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="count" type="text" default="5" label="COUNTLINKS"
Peter Martin – joomladays.nl – 13 June
description="COUNTDESCR" /> 2009 40
Module - MVC style: 4. screen output
/tmpl/default.php
<?php defined('_JEXEC')
or die('Restricted access'); ?>
<ul>
<?php foreach ($list as $item) : ?>
<li>
<a href="<?php echo $item->url; ?>"
title="<?php echo $item->description; ?>"
target="_blank">
<?php echo $item->title; ?></a>
</li>
<?php
Peter Martin endforeach;
– joomladays.nl – 13 June 2009 ?> 41
Module Diagram: 1. root file
mod_db8latestweblinks.php
helper.php
class modDB8LatestWeblinksHelper
{
jos_modules
function &getItems(&$params){
// [retrieve parameters]
// [return data]
}
Peter Martin – joomladays.nl – 13 June 2009 43
Module Diagram: 3. installer file
not used during process
0. Joomla
only for installing & configuration
jos_modules
3. Layout file
mod_db8latestweblinks.php jos_modules
'mod_db8latestweblinks'));
3. Layout file
/tmpl/default.php
<ul> jos_modules
<?php foreach ($list as $item) : ?>
<li>
<a href="<?php echo $item->url; ?>"
title="<?php echo $item->description; ?>"
jos_weblinks
target="_blank">
<?php echo $item->title; ?></a>
</li>
<?php
Peter Martin – endforeach; ?>
joomladays.nl – 13 June 2009 46
Distribution – packaging 1/2
mod_db8latestweblinks.xml +
<files>
<filename module="mod_db8latestweblinks">
mod_db8latestweblinks.php</filename>
<filename>index.html</filename>
<filename>helper.php</filename>
<filename>tmpl/index.html</filename>
<filename>tmpl/default.php</filename>
</files>
<languages>
<language tag="en-GB">en-GB.mod_db8latestweblinks.ini</language>
<language tag="nl-NL">nl-NL.mod_db8latestweblinks.ini</language>
</languages>
mod_db8latestweblinks.zip
Peter Martin
e-mail: info at db8.nl
website: www.db8.nl