我用admin
前缀设置了路由,我遇到问题的页面有以下路径:
http://mydomain.com/admin/posts
我希望这是一个博客文章的分页列表。该URL调用我的posts
控制器中的admin_index
操作。很简单。
在我的观点的底部,我有这样的:
<?php echo $this->Paginator->numbers(array('first' => 1, 'last' => 1, 'separator' => '')); ?>
然而,分页链接将我发送到一个不存在的URL:
http://mydomain.com/posts/admin_index/page:2
我需要它来生成一个链接,例如:
http://mydomain.com/admin/posts/2
我该怎么做?我已经尝试过设置我的分页器选项如下:
<?php $this->Paginator->options(array(
'url'=> array('controller' => 'posts',
'action' => 'index',
'prefix' => 'admin'
))); ?>
但这使得URL是这样的:
http://mydomain.com/posts/index/prefix:admin/page:2
我怎样才能让它发挥作用?
请阅读文档中关于前缀路由的部分:http://book.cakephp.org/2.0/en/development/routing.html#prefix-路由
尤其是你需要告诉蛋糕你想在应用程序中使用哪些路线的部分:
Configure::write('Routing.prefixes', array('admin'));
然后你的路由将在你的分页中工作。