Are you using Cake 1.2, or 1.1.18?
It is much easier to use pagination in 1.2, simply have:

function index(){
  $this->set( 'posts', $this->Post->paginate() );
}

I'm not sure what you mean about "create a function called index()" -
your sample code there already has this...  You can use pagination on
any action, not just "index" if that is what you are asking...


On Nov 16, 7:15 am, butangphp <[EMAIL PROTECTED]> wrote:
> I'm a beginner and struggling to use pagination correctly in cakephp.
> The Bakery recommends using this code in the controller.  I know its a
> dumb question, but do I need to create a function called index() in
> order to make this built in helper work ??
>
> <?php
> class PostsController extends AppController
> {
>     var $name = 'Posts'; // for PHP4 installs
>     var $components = array ('Pagination'); // Added
>     var $helpers = array('Pagination'); // Added
>
>     function index() {
>         $criteria=NULL;
>         list($order,$limit,$page) = $this->Pagination->init($criteria); // 
> Added
>
>         $data = $this->Post->findAll($criteria, NULL, $order, $limit,
> $page); // Extra parameters added
>
>         $this->set('data',$data);
>     }}
>
> ?>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to