我正在使用cakePHP 1.26。错误的网址导致分页
在PostsController,我有这样的:
$this->paginate=array('conditions'=>array('Reply.post_id'=>$id),'limit' => 1);
$w = $this->paginate($this->Post->Reply);
$this->set('views', $w);
而在view.ctp,我有这样的:
<table><tr><td>
<?php echo $paginator->numbers(); ?>
<?php
echo $paginator->prev('Previous', null, null);
echo $paginator->next(' Next', null, null);?>
</td></tr></table>
当我按了 “下一步” 的链接,一个错误的URL结果表明:
http://localhost:8080/post/view/page:2
正确的URL应该是
http://localhost:8080/post/view/2/page:2
指后该ID后丢失/后/视图/
能不能帮我解决这个问题吗?我添加到view.ctp:
$ paginator-> options(数组('url'=> $ this-> passedArgs));
现在,下一个和上一个链接已更正,但Next和Previous链接之间的数字仍然不正确。
这里是什么上一页和下一页链接llok像算账:
http://localhost:8080/post/view/2/page:2
但代表的数字链接1 | 2 | 3 | 4 | 5尚未改变:
http://localhost:8080/post/view/page:2
有任何想法吗?
编辑原因: OK,
我改变了我的代码,并得到了问题的新的答案:
这里是我的view.ctp文件中的代码:
<?php
$paginator->options(array('url' => '../view/'.$postid));
echo $paginator->numbers();
echo $paginator->prev('Previous', null, null);
echo $paginator->next(' Next', null, null);
?>