我是 Cakephp 的新手,我被这件事困住了。我的代码工作正常,但现在我需要对我的代码进行一些修改。当我尝试通过不同的页面对视图进行分页时,它可以工作,但是由于每个页面仅获取 20 个帖子,因此要查看下一个帖子,我会更改页面。现在第 20 个帖子在我的视图中,并且单击使用 ajax 的按钮我想在同一页面上显示下一个 20 个帖子(我不想重定向到页面以查看所有评论)请帮助.. .
这是我为显示不同页面的视图而调用的操作。
public function view($slug) {
$topic = $this->Topic->getBySlug($slug);
$user_id = $this->Auth->user('id');
$post_count = $topic['Topic']['post_count'];
$this->paginate['Post']['conditions'] = array('Post.topic_id' => $topic['Topic']['id']);
if ($this->RequestHandler->isRss()) {
$this->set('posts', $this->paginate('Post'));
$this->set('topic', $topic);
return;
}
if (!empty($this->request->data['Poll']['option'])) {
$this->Topic->Poll->vote($topic['Poll']['id'], $this->request->data['Poll']['option'], $user_id);
$this->Topic->deleteCache(array('Topic::getBySlug', $slug));
$this->redirect(array('plugin' => 'forum', 'controller' => 'topics', 'action' => 'view', $slug));
}
$this->ForumToolbar->markAsRead($topic['Topic']['id']);
$this->Topic->increaseViews($topic['Topic']['id']);
$this->ForumToolbar->pageTitle($topic['Topic']['title']);
$this->set('topic', $topic);
$this->set('posts', $this->paginate('Post'));
$this->render('view_new');
}