Thursday, May 8, 2014

Re: CakePHP 2.4.6 Paginator

Why are you doing a find and then a paginate ?

I think you should set conditions to paginator....

El jueves, 8 de mayo de 2014 09:29:19 UTC-3, Саша Кузьменко escribió:
my view $this->Paginator->params() show data:

2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  
array(      'Category' => array(          'page' => (int) 1,          'current' => (int) 1,          'count' => (int) 1,          'prevPage' => false,          'nextPage' => false,          'pageCount' => (int) 1,          'order' => array(),          'limit' => (int) 5,          'options' => array(              'sort' => 'price',              'direction' => 'asc',              'order' => array()          ),          'paramType' => 'named'      ),      'Product' => array(          'page' => (int) 1,          'current' => (int) 5,          'count' => (int) 7,          'prevPage' => false,          'nextPage' => true,          'pageCount' => (int) 2,          'order' => array(              'Product.price' => 'asc'          ),          'limit' => (int) 5,          'options' => array(              'sort' => 'price',              'direction' => 'asc',              'order' => array(                  'Product.price' => 'asc'              )          ),          'paramType' => 'named'      )  )
On my controller i set data:
1  2  3  4  5  
$products = $this->Category->Product->find('all', array(          'conditions' => array('Product.category_id' => $id)      ));  //    debug($products);  $this->set('products', $this->paginate('Product'));
and I'm trying to make paging:
 echo $this->Paginator->counter(array(      'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')      ));      ?>  </p>      <div class="paging">      <?php          echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));          echo $this->Paginator->numbers(array('separator' => ''));          echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));      ?>      </div>

But i get wrong data, i also add screen. Can someone help me, how to make true paging here???

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: