cakephp - 如何使用附加参数 cakephp 传递分页参数?

标签 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 页上的结果相同。

我哪里出错了?

最佳答案

感谢 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/

相关文章:

$.post通过jquery提交后,Cakephp清空$this->data

php - Cakephp:多个文件上传字段自动设置为必填

cakephp - 在 CakePHP 中动态创建虚拟字段

cakephp - 用户 session 和在同一台计算机上运行的两个 CakePHP 应用程序

java - 具有多个 JTable 的大型 JScrollPane — 如何分页

php - cakePHP 示例中的插件

cakephp - 我怎样才能得到cakephp当前模型的外键列名?

cakephp - 如何获取当前记录的ID?

spring - 如何为 Spring MVC 添加简单的分页

java - 使用 Selenium 通过分页导航将项目添加到 HashMap