Prev | Current Page 165 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"

Incorporating the functions in a static class reduces the chance of conflict
with other extensions and the core.
Module Design
[ 122 ]
We normally name module helper classes using the naming convention: the word
mod, the module name, the word Helper. For example, a helper class for the module
My Extension would be called modMyExtensionHelper.
Module helper classes are normally located in a file called helper.php in the root of
the module. In this example, we define the class modMyExtensionHelper and create
a method called getItems():
/**
* My Extension Module Helper
*
* @static
*/
class modMyExtensionHelper
{
/**
* Gets an array of items
*
* @param JParameter Module parameters
* @return mixed Array of items, false on failure
*/
function &getItems(&$params)
{
$db =& JFactory::getDBO();
$category = $params->get('category', 0);
$query = modMyExtensionHelper::_buildQuery($category);
$db->setQuery($query);
$instance = $db->loadObjectList();
return $instance;
}
/**
* Gets an SQL query string
*
* @param JParameter Module parameters
* @return string SQL query
*/
function _buildQuery($category)
{
$db =& JFactory::getDBO();
return 'SELECT * FROM '.


Pages:
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
perfumy fm Stal rezerwacja hoteli pomiary wiatru Nike Buty Męskie Air Flex Trainer Lea