Now exam the controller for backend and the procedures of handling a request.
In admin.joomsport.php:
function BL_TourList($option)
{
//$lim = JRequest::getVar('limit', null, '', 'int');
//dump($lim, 'lim'); // null
$mainframe = JFactory::getApplication();
//$us_lim = $mainframe->getUserState('global.list.limit');
//dump($us_lim, 's_lim'); // null
//$cg_lim = $mainframe->getCfg('list_limit');
//dump($cg_lim, 'cg_lim'); // '20'
$limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
$limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
$db =& JFactory::getDBO();
$query = "SELECT COUNT(*) FROM #__bl_tournament ORDER BY name";
$db->setQuery($query);
$total = $db->loadResult();
jimport('joomla.html.pagination');
$pageNav = new JPagination( $total, $limitstart, $limit );
$query = "SELECT * FROM #__bl_tournament ORDER BY name";
$db->setQuery($query, $pageNav->limitstart, $pageNav->limit);
$rows = $db->loadObjectList();
joomsport_html::bl_TournList($rows, $pageNav, $option);
}
This is the method for task 'tour_list'.
function getUserStateFromRequest( $key, $request, $default = null, $type = 'none' )
{
$old_state = $this->getUserState( $key );
$cur_state = (!is_null($old_state)) ? $old_state : $default;
$new_state = JRequest::getVar($request, null, 'default', $type);
// Save the new value only if it was set in this request
if ($new_state !== null) {
$this->setUserState($key, $new_state);
} else {
$new_state = $cur_state;
}
return $new_state;
}
REFS:
http://docs.joomla.org/How_to_use_user_state_variables
PHP Cross Reference of Joomla 1.5.6 Documentation
JApplication/getUserStateFromRequest
JApplication/getCfg