joomla分页在每个页面上显示相同的结果

joomla分页在每个页面上显示相同的结果,joomla,pagination,Joomla,Pagination,我有超过5个结果的文章页。每页显示5个结果。分页显示。但是,当我转到不同的页面时,每个页面都有相同的5个结果 My getItems(): 我的国家: protected function populateState($ordering = null, $direction = null) { // Initiliase variables. $app = JFactory::getApplication('site'); $pk

我有超过5个结果的文章页。每页显示5个结果。分页显示。但是,当我转到不同的页面时,每个页面都有相同的5个结果

My getItems():

我的国家:

protected function populateState($ordering = null, $direction = null)
    {
        // Initiliase variables.
        $app    = JFactory::getApplication('site');
        $pk     = JRequest::getInt('id');

        $this->setState('category.id', $pk);

        // Load the parameters. Merge Global and Menu Item params into new object
        $params = $app->getParams();
        $menuParams = new JRegistry;

        if ($menu = $app->getMenu()->getActive()) {
            $menuParams->loadString($menu->params);
        }

        $mergedParams = clone $menuParams;
        $mergedParams->merge($params);

        $this->setState('params', $mergedParams);
        $user       = JFactory::getUser();
                // Create a new query object.
        $db     = $this->getDbo();
        $query  = $db->getQuery(true);
        $groups = implode(',', $user->getAuthorisedViewLevels());

        if ((!$user->authorise('core.edit.state', 'com_content')) &&  (!$user->authorise('core.edit', 'com_content'))){
            // limit to published for people who can't edit or edit.state.
            $this->setState('filter.published', 1);

            /**
             * Custom Author Filter
             */
            if (JRequest::getVar('author')) {
                $this->setState('filter.created_by', $this->getUserId(JRequest::getVar('author')));
            }

            // Filter by start and end dates.
            $nullDate = $db->Quote($db->getNullDate());
            $nowDate = $db->Quote(JFactory::getDate()->toMySQL());

            $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
            $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');

            /**
             * Custom Author Filter
             */
            if (JRequest::getVar('author')) {
                $query->where('(a.created_by = "' . $this->getUserId(JRequest::getVar('author')) . '")');
            }
        }


        // process show_noauth parameter
        if (!$params->get('show_noauth')) {
            $this->setState('filter.access', true);
        }
        else {
            $this->setState('filter.access', false);
        }

        // Optional filter text
        $this->setState('list.filter', JRequest::getString('filter-search'));

        // filter.order
        $itemid = JRequest::getInt('id', 0) . ':' . JRequest::getInt('Itemid', 0);
        $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
        if (!in_array($orderCol, $this->filter_fields)) {
            $orderCol = 'a.ordering';
        }
        $this->setState('list.ordering', $orderCol);

        $listOrder = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir',
            'filter_order_Dir', '', 'cmd');
        if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) {
            $listOrder = 'ASC';
        }
        $this->setState('list.direction', $listOrder);

        //$this->setState('list.start', JRequest::getVar('limitstart', 0, '', 'int'));

        // set limit for query. If list, use parameter. If blog, add blog parameters for limit.
        if ((JRequest::getCmd('layout') == 'blog') || $params->get('layout_type') == 'blog') {
            $limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links');
            $this->setState('list.links', $params->get('num_links'));
        }
        else {
            $limit = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.limit', 'limit', $params->get('display_num'));
        }

        $this->setState('list.limit', $limit);

        // set the depth of the category query based on parameter
        $showSubcategories = $params->get('show_subcategory_content', '0');

        if ($showSubcategories) {
            $this->setState('filter.max_category_levels', $params->get('show_subcategory_content', '1'));
            $this->setState('filter.subcategories', true);
        }



        $this->setState('filter.language',$app->getLanguageFilter());

        $this->setState('layout', JRequest::getCmd('layout'));

    }
受保护函数populateState($ordering=null,$direction=null)
{
//初始化变量。
$app=JFactory::getApplication('site');
$pk=JRequest::getInt('id');
$this->setState('category.id',$pk);
//加载参数。将全局和菜单项参数合并到新对象中
$params=$app->getParams();
$menuParams=新的JRegistry;
如果($menu=$app->getMenu()->getActive()){
$menuParams->loadString($menu->params);
}
$mergedParams=克隆$menuParams;
$mergedParams->merge($params);
$this->setState('params',$mergedParams);
$user=JFactory::getUser();
//创建一个新的查询对象。
$db=$this->getDbo();
$query=$db->getQuery(true);
$groups=内爆(“,”,$user->getAuthorizedViewLevel());
如果(!$user->authorize('core.edit.state','com\u content')和(!$user->authorize('core.edit','com\u content')){
//限制为无法编辑或编辑.state的用户发布。
$this->setState('filter.published',1);
/**
*自定义作者筛选器
*/
if(JRequest::getVar('author')){
$this->setState('filter.created_by',$this->getUserId(JRequest::getVar('author'));
}
//按开始日期和结束日期筛选。
$nullDate=$db->Quote($db->getNullDate());
$nowDate=$db->Quote(JFactory::getDate()->toMySQL());
$query->where(‘(a.publish_-up=‘.$nullDate.’或a.publish_-up=‘.$nowDate.)’);
/**
*自定义作者筛选器
*/
if(JRequest::getVar('author')){
$query->where('(a.created_by=“”。$this->getUserId(JRequest::getVar('author'))。'));
}
}
//进程显示\u noauth参数
如果(!$params->get('show_noauth')){
$this->setState('filter.access',true);
}
否则{
$this->setState('filter.access',false);
}
//可选筛选文本
$this->setState('list.filter',JRequest::getString('filter-search');
//过滤顺序
$itemid=JRequest::getInt('id',0)。':'。JRequest::getInt('itemid',0);
$orderCol=$app->getUserStateFromRequest('com_content.category.list.'.$itemid.'.filter_order','filter_order','string');
如果(!in_数组($orderCol,$this->filter_字段)){
$orderCol='a.ordering';
}
$this->setState('list.ordering',$orderCol);
$listOrder=$app->getUserStateFromRequest('com\u content.category.list.'.$itemid.'.filter\u order\u Dir',
“过滤器顺序目录”,“命令目录”;
if(!in_数组(strtoupper($listOrder),数组('ASC','DESC','')){
$listOrder='ASC';
}
$this->setState('list.direction',$listOrder);
//$this->setState('list.start',JRequest::getVar('limitstart',0','int');
//为查询设置限制。如果是列表,则使用参数。如果是博客,则为限制添加博客参数。
如果((JRequest::getCmd('layout')=='blog')| |$params->get('layout_type')=='blog')){
$limit=$params->get('num_leading_articles')+$params->get('num_intro_articles')+$params->get('num_links');
$this->setState('list.links',$params->get('num_links');
}
否则{
$limit=$app->getUserStateFromRequest('com_content.category.list.'.$itemid.'.limit','limit',$params->get('display_num');
}
$this->setState('list.limit',$limit);
//根据参数设置类别查询的深度
$showSubcategories=$params->get('show_subcategority_content','0');
如果($showSubcategories){
$this->setState('filter.max_category_levels',$params->get('show_subcategory_content','1');
$this->setState('filter.subcategories',true);
}
$this->setState('filter.language',$app->getLanguageFilter());
$this->setState('layout',JRequest::getCmd('layout');
}
我的显示函数de view.html.php

function display($tpl = null)
    {
        $app    = JFactory::getApplication();
        $user   = JFactory::getUser();

        // Get some data from the models
        $state      = $this->get('State');

        $params     = $state->params;
        $items      = $this->get('Items');

        $contactId = JRequest::getVar('author');
        if($contactId){
            $this->setUserId($contactId);
            $this->setContactName($this->userId);
        }

        $category   = $this->get('Category');
        $children   = $this->get('Children');
        $parent     = $this->get('Parent');
        $pagination = $this->get('Pagination');


        // Check for errors.
        if (count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode("\n", $errors));
            return false;
        }

        if ($category == false) {
            return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
        }

        if ($parent == false) {
            return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
        }

        // Setup the category parameters.
        $cparams = $category->getParams();
        $category->params = clone($params);
        $category->params->merge($cparams);

        // Check whether category access level allows access.
        $user   = JFactory::getUser();
        $groups = $user->getAuthorisedViewLevels();
        if (!in_array($category->access, $groups)) {
            return JError::raiseError(403, JText::_("JERROR_ALERTNOAUTHOR"));
        }

        // PREPARE THE DATA
        // Get the metrics for the structural page layout.
        $numLeading = $params->def('num_leading_articles', 1);
        $numIntro   = $params->def('num_intro_articles', 4);
        $numLinks   = $params->def('num_links', 4);

        // Compute the article slugs and prepare introtext (runs content plugins).

        for ($i = 0, $n = count($items); $i < $n; $i++)
        {
            $item = &$items[$i];
            $item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;

            // No link for ROOT category
            if ($item->parent_alias == 'root') {
                $item->parent_slug = null;
            }

            $item->event = new stdClass();

            $dispatcher = JDispatcher::getInstance();

            // Ignore content plugins on links.
            if ($i < $numLeading + $numIntro) {
                $item->introtext = JHtml::_('content.prepare', $item->introtext);

                $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$item->params, 0));
                $item->event->afterDisplayTitle = trim(implode("\n", $results));

                $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$item->params, 0));
                $item->event->beforeDisplayContent = trim(implode("\n", $results));

                $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$item->params, 0));
                $item->event->afterDisplayContent = trim(implode("\n", $results));
            }
        }

        // Check for layout override only if this is not the active menu item
        // If it is the active menu item, then the view and category id will match

        $active = $app->getMenu()->getActive();

        if ((!$active) || ((strpos($active->link, 'view=category') === false) || (strpos($active->link, '&id=' . (string) $category->id) === false))) {
            // Get the layout from the merged category params
            if ($layout = $category->params->get('category_layout')) {
                $this->setLayout($layout);
            }
        }
        // At this point, we are in a menu item, so we don't override the layout
        elseif (isset($active->query['layout'])) {
            // We need to set the layout from the query in case this is an alternative menu item (with an alternative layout)
            $this->setLayout($active->query['layout']);
        }

        // For blog layouts, preprocess the breakdown of leading, intro and linked articles.
        // This makes it much easier for the designer to just interrogate the arrays.
        if (($params->get('layout_type') == 'blog') || ($this->getLayout() == 'blog')) {
            $max = count($items);

            // The first group is the leading articles.
            $limit = $numLeading;
            for ($i = 0; $i < $limit && $i < $max; $i++) {
                $this->lead_items[$i] = &$items[$i];
            }

            // The second group is the intro articles.
            $limit = $numLeading + $numIntro;
            // Order articles across, then down (or single column mode)
            for ($i = $numLeading; $i < $limit && $i < $max; $i++) {
                $this->intro_items[$i] = &$items[$i];
            }

            $this->columns = max(1, $params->def('num_columns', 1));
            $order = $params->def('multi_column_order', 1);

            if ($order == 0 && $this->columns > 1) {
                // call order down helper
                $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns);
            }

            $limit = $numLeading + $numIntro + $numLinks;
            // The remainder are the links.
            for ($i = $numLeading + $numIntro; $i < $limit && $i < $max;$i++)
            {
                    $this->link_items[$i] = &$items[$i];
            }
        }

        $children = array($category->id => $children);

        //Escape strings for HTML output
        $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));


        $this->assign('maxLevel', $params->get('maxLevel', -1));
        $this->assignRef('state', $state);
        $this->assignRef('items', $items);
        $this->assignRef('category', $category);
        $this->assignRef('children', $children);
        $this->assignRef('params', $params);
        $this->assignRef('parent', $parent);
        $this->assignRef('pagination', $pagination);
        $this->assignRef('user', $user);
        $this->_prepareDocument();
        parent::display($tpl);
    }
功能显示($tpl=null)
{
$app=JFactory::getApplication();
$user=JFactory::getUser();
//从模型中获取一些数据
$state=$this->get('state');
$params=$state->params;
$items=$this->get('items');
$contactId=JRequest::getVar('author');
如果($contactId){
$this->setUserId($contactId);
$this->setContactName($this->userId);
}
$category=$this->get('category');
$children=$this->get('children');
$parent=$this->get('parent');
$pagination=$this->get('pagination');
//检查错误。
如果(计数($errors=$this->get('errors')){
JError::raiseError(500,内爆(“\n”,$errors));
返回false;
}
如果($category==false){
return JError::raiseError(404,JText::((“JGLOBAL_CATEGORY_NOT_FOUND”);
}
如果($parent==false){
return JError::raiseError(404,JText::((“JGLOBAL_CATEGORY_NOT_FOUND”);
}
//设置类别参数。
$cparams=$category->getParams();
$category->params=克隆($params);
$category->params->merge($cparams);
//检查类别访问级别是否允许访问。
$user=JFactory::getUser();
$groups=$user->GetAuthorizedViewLevel();
如果(!在数组中($category->access,$groups)){
return JError::raiseError(403,JText::(“JError\u ALERTNOAUTHOR”)
function display($tpl = null)
    {
        $app    = JFactory::getApplication();
        $user   = JFactory::getUser();

        // Get some data from the models
        $state      = $this->get('State');

        $params     = $state->params;
        $items      = $this->get('Items');

        $contactId = JRequest::getVar('author');
        if($contactId){
            $this->setUserId($contactId);
            $this->setContactName($this->userId);
        }

        $category   = $this->get('Category');
        $children   = $this->get('Children');
        $parent     = $this->get('Parent');
        $pagination = $this->get('Pagination');


        // Check for errors.
        if (count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode("\n", $errors));
            return false;
        }

        if ($category == false) {
            return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
        }

        if ($parent == false) {
            return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
        }

        // Setup the category parameters.
        $cparams = $category->getParams();
        $category->params = clone($params);
        $category->params->merge($cparams);

        // Check whether category access level allows access.
        $user   = JFactory::getUser();
        $groups = $user->getAuthorisedViewLevels();
        if (!in_array($category->access, $groups)) {
            return JError::raiseError(403, JText::_("JERROR_ALERTNOAUTHOR"));
        }

        // PREPARE THE DATA
        // Get the metrics for the structural page layout.
        $numLeading = $params->def('num_leading_articles', 1);
        $numIntro   = $params->def('num_intro_articles', 4);
        $numLinks   = $params->def('num_links', 4);

        // Compute the article slugs and prepare introtext (runs content plugins).

        for ($i = 0, $n = count($items); $i < $n; $i++)
        {
            $item = &$items[$i];
            $item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;

            // No link for ROOT category
            if ($item->parent_alias == 'root') {
                $item->parent_slug = null;
            }

            $item->event = new stdClass();

            $dispatcher = JDispatcher::getInstance();

            // Ignore content plugins on links.
            if ($i < $numLeading + $numIntro) {
                $item->introtext = JHtml::_('content.prepare', $item->introtext);

                $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.article', &$item, &$item->params, 0));
                $item->event->afterDisplayTitle = trim(implode("\n", $results));

                $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.article', &$item, &$item->params, 0));
                $item->event->beforeDisplayContent = trim(implode("\n", $results));

                $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.article', &$item, &$item->params, 0));
                $item->event->afterDisplayContent = trim(implode("\n", $results));
            }
        }

        // Check for layout override only if this is not the active menu item
        // If it is the active menu item, then the view and category id will match

        $active = $app->getMenu()->getActive();

        if ((!$active) || ((strpos($active->link, 'view=category') === false) || (strpos($active->link, '&id=' . (string) $category->id) === false))) {
            // Get the layout from the merged category params
            if ($layout = $category->params->get('category_layout')) {
                $this->setLayout($layout);
            }
        }
        // At this point, we are in a menu item, so we don't override the layout
        elseif (isset($active->query['layout'])) {
            // We need to set the layout from the query in case this is an alternative menu item (with an alternative layout)
            $this->setLayout($active->query['layout']);
        }

        // For blog layouts, preprocess the breakdown of leading, intro and linked articles.
        // This makes it much easier for the designer to just interrogate the arrays.
        if (($params->get('layout_type') == 'blog') || ($this->getLayout() == 'blog')) {
            $max = count($items);

            // The first group is the leading articles.
            $limit = $numLeading;
            for ($i = 0; $i < $limit && $i < $max; $i++) {
                $this->lead_items[$i] = &$items[$i];
            }

            // The second group is the intro articles.
            $limit = $numLeading + $numIntro;
            // Order articles across, then down (or single column mode)
            for ($i = $numLeading; $i < $limit && $i < $max; $i++) {
                $this->intro_items[$i] = &$items[$i];
            }

            $this->columns = max(1, $params->def('num_columns', 1));
            $order = $params->def('multi_column_order', 1);

            if ($order == 0 && $this->columns > 1) {
                // call order down helper
                $this->intro_items = ContentHelperQuery::orderDownColumns($this->intro_items, $this->columns);
            }

            $limit = $numLeading + $numIntro + $numLinks;
            // The remainder are the links.
            for ($i = $numLeading + $numIntro; $i < $limit && $i < $max;$i++)
            {
                    $this->link_items[$i] = &$items[$i];
            }
        }

        $children = array($category->id => $children);

        //Escape strings for HTML output
        $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));


        $this->assign('maxLevel', $params->get('maxLevel', -1));
        $this->assignRef('state', $state);
        $this->assignRef('items', $items);
        $this->assignRef('category', $category);
        $this->assignRef('children', $children);
        $this->assignRef('params', $params);
        $this->assignRef('parent', $parent);
        $this->assignRef('pagination', $pagination);
        $this->assignRef('user', $user);
        $this->_prepareDocument();
        parent::display($tpl);
    }
$this->_prepareDocument();

        echo '<pre>'; print_r($pagination); exit(); 
        parent::display($tpl);
<?php echo $this->pagination->getPagesLinks(); ?>
$this->setState('list.start', JRequest::getVar('limitstart', 0, '', 'int'));
$this->setState('list.start', JRequest::getVar('start', 0, '', 'int'));