【发布时间】:2013-07-28 23:51:36
【问题描述】:
我有一个类别列表,其中显示了它下面的项目列表。
因此:
路线有:
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 页上的结果相同。
任何想法我哪里出错了?
【问题讨论】:
-
下一个/上一个链接指向什么 url? IME 你最好使用 get params 作为分页变量。
-
他们显示
/:slug/:page,如/Calculators/2 -
/Calculators/2与问题中的任何一条路线都不匹配。 -
@AD7six 能否请您对“获取分页变量的参数”进行一些说明? PS:我不在乎 URL 看起来是否丑陋。我只需要正确的结果,但是,我需要输入 $this->paginate->options URL,因为我使用的是 slug,否则它会重定向到 /controller/action/:page
-
using get params for pagination 请只用您使用的蛋糕版本标记您的问题 - 是 2.0 还是 2.3?
标签: cakephp pagination cakephp-2.3