Is the news action diff from index? I think you may need to set some props of the paginator helper.
- S On 13 Jan 2012 07:45, "Chooch Schubert" <[email protected]> wrote: > I have followed the 2.0 book to add pagination to a controller/view. I > get the paginate controls and they are rendering correctly (they > *think* I'm doing things like next page and sort when I click on the > links since they change their counts and links) however the data > returned isn't paginated. > > I should only be seeing 10 posts, but I am getting all posts in the > database (about 30) no matter what I click on. > > Any pointers? > > The code in the PostsController.php looks like: > <?php > class PostsController extends AppController { > public $name = 'Posts'; > public $helpers = array('Html', 'Form', 'Paginator'); > public $components = array('Session'); > > public $paginate = array( > 'limit' => 5, > 'order' => array( > 'Post.title' => 'asc' > ) > ); > > public function news() { > $this->paginate ('Post'); > $this->set('posts', $this->Post->find('all')); > } > > The code in the view looks like: > <table> > <tr> > <th width=25%><?php echo $this->Paginator->sort('title', > 'Title'); ?></th> > <th><?php echo $this->Paginator->sort('body', 'Content'); ?></ > th> > </tr> > <?php foreach ($posts as $post): ?> > <tr> > <td><?php echo $post['Post']['title']; ?> </td> > <td><?php echo $post['Post']['body']; ?> </td> > </tr> > <?php endforeach; ?> > </table> > > <?php > // Shows the page numbers > echo $this->Paginator->numbers(); > > // Shows the next and previous links > echo $this->Paginator->prev('« Previous', null, null, array('class' => > 'disabled')); > echo $this->Paginator->next('Next »', null, null, array('class' => > 'disabled')); > > // prints X of Y, where X is current page and Y is number of pages > echo $this->Paginator->counter(); > ?> > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected] For more options, visit this group > at http://groups.google.com/group/cake-php > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
