如何使用额外的params cakephp传递分页参数?

时间:2013-07-28 15:31:07

标签: cakephp pagination cakephp-2.3

我有一个类别列表,显示其下的项目列表。

因此:

路线有:

Router::connect('/category/:slug', array('controller' => 'Product',
             'action'=>'catview', 'slug'=> '[0-9a-zA-Z]+'));
Router::connect('/category/:slug/:page', array('controller' => 'Product',
             'action'=>'catview','slug'=> '[0-9a-zA-Z]+','page'=>'[0-9]+'));

当我在结果页面中执行此操作时,它不起作用:

<?php 
        $slug = $this->params['slug'];
        $this->Paginator->options(array('url'=> array('controller' => 'Product',
                             'action'=>'catview','slug'=> $slug)));

        echo $this->Paginator->prev('<< Show me previous', array('class'=>'prev'))
        . $this->Paginator->next('Show me more >>', array('class'=>'next')); ?>

它不会改变结果,它显示与第1页相同的结果。

我出错的任何想法?

1 个答案:

答案 0 :(得分:6)

感谢AD7six提供参考。

我的控制器需要:

$this->paginate = array(
 //other stuff here
 'paramType' => 'querystring'
);

其次是:

$this->Paginator->options(array('url'=> array('controller' => 'Product',
                                  'action'=>'catview','slug'=> $slug),
                                     'convertKeys' => array('page')));
视图文件中的

相关问题