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

Publishing records


When we first built out the backend for managing the reviews, the Publish and Unpublish buttons were added. However, if you try to use these buttons right now, they have no effect. Logic must be added to the controller to handle the publish and unpublish tasks. Let's start with the publish task. Edit the /administrator/components/com_restaurants/restaurants.php file, and add the following function to the RestaurantsController class:

function publish()
{
global $option;
$cid = JRequest::getVar('cid', array());
$row =& JTable::getInstance('review', 'Table');
if(!$row->publish($cid))
{
JError::raiseError(500, $row->getError() );
}
$s = '';
if (count($cid) > 1)
{
$s = 's';
}
$this->setRedirect('index.php?option=' . $option, 'Review' . $s . ' published.');
}

This function first pulls the $option variable from global scope and extracts the cid request variable. Next, an instance of TableReview is fetched and stored in $row. If we were saving a complete TableReview...