Joomla! (DAY 8) - Joomsport (DAY 6):

62 篇文章 0 订阅
44 篇文章 0 订阅

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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值