SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 167 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"

This example shows how we might
choose to implement this:
/**
* Gets an array of items
*
* @param JParameter Module parameters
* @return mixed Array of items, false on failure
*/
function &getItems(&$params)
{
static $instances;
if (!isset($instances))
{
$instances = array();
}
$category = $params->get('category', 0);
if (empty($instances[$category]))
{
$db =& JFactory::getDBO();
$query = modMyExtensionHelper::_buildQuery($category);
$db->setQuery($query);
@$instances[$category] = $db->loadObjectList();
}
return $instances[$category];
}
Note that we have renamed $instance to $instances and that
it is now an array.
Module Design
[ 124 ]
This is an example of how we would use the helper we have just defined, and use the
getItems() method. This assumes we are in the root module file and hence $params
is available to us.
require_once(dirname(__FILE__).DS.'helper.php');
$items =& modMyExtensionHelper::getItems($params);
Once we have done this, we could then verify that $items is an array.


Pages:
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6