我正在使用来自 cakedc.com 的标签插件,但在使用 PaginatorHelper 生成正确的分页链接时遇到问题。
期望的结果是从生成的 href 中去除插件名称,因为插件将添加到路由中。即http://localhost /tags /photos/oregon/page:4/perpage:28
这就是我所拥有的:
app/config/routes.php(映射'/tags'=>'/tags/tags',即映射到标签插件)
Router::connect('/tags/:action/*', array('plugin'=>'tags', 'controller'=>'tags'));
// map /tags => /tags/tags
视图文件中的代码:
<?php
$this->Paginator->options['url']=array_merge(
array('plugin'=>'tags'),
$this->Paginator->options['url']
);
echo $this->Paginator->numbers(array('separator'=>null, 'modulus'=>'20'));
// debug($this->Paginator->options[url] => Array
// (
// [controller] => tags
// [action] => photos
// [0] => oregon
// [perpage] => 28
// [page] => 4
// )
// )
// sample href="http://localhost/tags/tags/photos/oregon/page:4/perpage:28"
// note the '/tags/tags' i.e. /:plugin/:controller
?>
BU,如果我将 options['url'] 设置如下:
<?php
$this->Paginator->options['url']=array('plugin'=>'tags');
echo $this->Paginator->numbers(array('separator'=>null, 'modulus'=>'20'));
// debug($this->Paginator->options[url] => Array
// (
// [plugin] => tags
// )
// )
// sample href="http://localhost/tags/photos/page:4"
?>