所以,我所拥有的是一个显示帖子的页面。帖子被收集到项目中。而且,在这个页面上,除了帖子之外,我还会显示同一项目的上一篇和下一篇文章。所以,我的控制器中有这个:
$this->set("post", $this->Post->find("first", array("conditions" => array("Post.id" => $id), "contain" => array("User", "Project", "Project.Post" => array("id", "image", "title"), "Comment", "Comment.User" => array("id", "username", "mail"), "Comment.User.Post" => array("id", "image", "title")))));
$this->set("neighbors", $this->Post->find("neighbors", array("field" => "id", "value" => $id)));
问题是它从所有帖子中获取上一个和下一个帖子,而不仅仅是同一个项目的帖子。
所以,如果你能帮助我一点:)