Book Image

Learning Joomla! 1.5 Extension Development

Book Image

Learning Joomla! 1.5 Extension Development

Overview of this book

Table of Contents (17 chapters)
Learning Joomla! 1.5 Extension Development
Credits
About the Author
About the Reviewer
Preface

Recruiting some helpers


We would like to have our module do more than just display links to the reviews. It would be helpful to include a summary of the review along with each link, and have the opportunity to display a random review. However, the way we currently have it coded is not sufficient to handle different scenarios efficiently. To fix this, we will centralize the data functions into a helper class. Create a file called helper.php in the /modules/mod_reviews folder and add the following code to this new file:

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
class modReviewsHelper
{
function getReviews(&$params)
{
$items = $params->get('items', 1);
$db =& JFactory::getDBO();
$query = "SELECT id, name, quicktake FROM #__reviews WHERE published = '1' ORDER BY review_date DESC";
$db->setQuery( $query, 0, $items );
$rows = $db->loadObjectList();
foreach ($rows as &$row)
{
$row->link = modReviewsHelper::makeReviewLink($row);
}
return $rows;
}
function...