开发者

CakePHP show Next / Previous link for posts

开发者 https://www.devze.com 2023-01-12 19:11 出处:网络
The CakePHP Blog Tutorial s开发者_开发百科hows a pagination view of all Blog posts. If in the view mode of a blog entry, how would I show a previous/next link to the posts before and after this one?

The CakePHP Blog Tutorial s开发者_开发百科hows a pagination view of all Blog posts. If in the view mode of a blog entry, how would I show a previous/next link to the posts before and after this one? Rather than having an index page with all posts listed I would like to click in blog view from post to post


From the Manual:

find('neighbors', $params)

'neighbors' will perform a find similar to 'first', but will return the row before and after the one you request. Below is a simple (controller code)

Example:

function some_function() {
   $neighbors = $this->Article->find('neighbors', array('fields' => 'id', 'value' => 3));
}


You can user the Post->find('neighbor') function for that.


Very nice explanation for this topic has been given here

Previous Next posts links in Cakephp

0

精彩评论

暂无评论...
验证码 换一张
取 消