duanbi8529 2013-06-26 21:37
浏览 48

分页链接不使用管理员前缀

I have routes set up with the admin prefix, the page I'm having trouble with has this path:

http://mydomain.com/admin/posts

I want this to be a paginated list of blog posts. That URL calls the admin_index action in my posts controller. Pretty simple.

At the bottom of my view I have this:

<?php echo $this->Paginator->numbers(array('first' => 1, 'last' => 1, 'separator' => '')); ?>

However, the pagination links send me to a URL that doesn't exist:

http://mydomain.com/posts/admin_index/page:2

I need it to generate a link such as:

http://mydomain.com/admin/posts/2

How can I do this? I've already tried setting my paginator options like so:

<?php $this->Paginator->options(array(
    'url'=> array('controller' => 'posts',
    'action' => 'index',
    'prefix' => 'admin'
))); ?>

But that makes a URL like so:

http://mydomain.com/posts/index/prefix:admin/page:2

How can I get this to work?

  • 写回答

1条回答 默认 最新

  • dq8081 2013-06-26 23:34
    关注

    Please read the section in the docs regarding prefixed routing: http://book.cakephp.org/2.0/en/development/routing.html#prefix-routing

    Especially the part where you need to tell cake which routes you want to use in your app:

    Configure::write('Routing.prefixes', array('admin'));
    

    Then your routing will work in your pagination.

    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路