I have an action called index and another one called manage, both in PostsController. I want to implement pagination for both, and I’ve set up this class attribute:
public $paginate = array(
'limit' => 10,
'order' => array(
'Post.created' => 'desc'
)
);
then I’m using the pagination in my index action like so: $this->set('posts', $this->paginate('Post'));
This results in a URL like so: http://dev/posts/page:2 which is fine.
However, when I try to use pagination in my manage action just like I did with index ($this->set('posts', $this->paginate('Post'));), the pagination links on my view redirect to the URL above, rather than the manage action.
Basically, Cake is getting confused because I’m using pagination twice in the same controller and it’s redirecting both to the same URL. How can I make sure that the pagination for the manage action works properly?
Do the followings.
make changes in view file as defined below.
index.ctp
manage.ctp
And you are done.