Kar*_*rma 4 pagination cakephp 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]+'));
Run Code Online (Sandbox Code Playgroud)
和
当我在结果页面中执行此操作时,它不起作用:
<?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')); ?>
Run Code Online (Sandbox Code Playgroud)
它不会更改结果,它显示与第1页相同的结果.
我出错的任何想法?
感谢AD7six作为参考.
我的控制器需要:
$this->paginate = array(
//other stuff here
'paramType' => 'querystring'
);
Run Code Online (Sandbox Code Playgroud)
其次是:
$this->Paginator->options(array('url'=> array('controller' => 'Product',
'action'=>'catview','slug'=> $slug),
'convertKeys' => array('page')));
Run Code Online (Sandbox Code Playgroud)
在视图文件中