我有一个类别列表,其中显示了其下的项目列表。
因此:
路线有:
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 页上的结果相同。
我哪里出错了?
最佳答案
感谢 AD7six供引用。
我的 Controller 需要:
$this->paginate = array(
//other stuff here
'paramType' => 'querystring'
);
其次是:
$this->Paginator->options(array('url'=> array('controller' => 'Product',
'action'=>'catview','slug'=> $slug),
'convertKeys' => array('page')));
在 View 文件中
关于cakephp - 如何使用附加参数 cakephp 传递分页参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17909833/