stargazer
stargazer

Reputation: 99

CakePHP show Next / Previous link for posts

The CakePHP Blog Tutorial shows 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

Upvotes: 1

Views: 1185

Answers (3)

Mahendra Singh
Mahendra Singh

Reputation: 1

Very nice explanation for this topic has been given here

Previous Next posts links in Cakephp

Upvotes: 0

harpax
harpax

Reputation: 6106

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

Upvotes: 0

quantumSoup
quantumSoup

Reputation: 28162

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));
}

Upvotes: 4

Related Questions