【发布时间】:2010-07-07 18:31:03
【问题描述】:
我使用的是 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
正确的网址应该是
http://localhost:8080/post/view/2/page:2
在 /post/view/ 之后缺少引用帖子的 ID
你能帮我解决这个问题吗?
我将此添加到 view.ctp:
$paginator->options(array('url' => $this->passedArgs));
现在下一个和上一个链接已更正,但
Next 和 Previous 链接之间的数字仍然不正确。
这是上一个和下一个链接之后的样子:
http://localhost:8080/post/view/2/page:2
但是代表数字 1|2|3|4|5 的链接还没有改变:
http://localhost:8080/post/view/page:2
有什么想法吗?
编辑原因:
好的,
我更改了我的代码并得到了问题的新答案:
这是我的 view.ctp 文件中的代码:
<?php
$paginator->options(array('url' => '../view/'.$postid));
echo $paginator->numbers();
echo $paginator->prev('Previous', null, null);
echo $paginator->next(' Next', null, null);
?>
【问题讨论】:
标签: cakephp cakephp-1.2