Ver Mensaje Individual
  #2 (permalink)  
Antiguo 17/12/2013, 05:30
nanotk58
 
Fecha de Ingreso: abril-2013
Mensajes: 61
Antigüedad: 11 años, 1 mes
Puntos: 4
Respuesta: CakePHP - Cómo muestro los resultados de paginado en vista?

Código PHP:
Ver original
  1. Cantidad <?php echo $this->Paginator->counter(array('format' => '%count%')); ?>

Luego yo suelo mostrar estos resultados en tablas, al th se le puede poner para que los ordene

Código PHP:
Ver original
  1. echo $this->Paginator->sort('User.id', 'id');

Para recorrerlo 1 a 1, con un foreach


Código PHP:
Ver original
  1. foreach($userPaginate as $data){
  2.     echo '<tr>';
  3.    
  4.         echo '<td>';
  5.         echo $data['User']['id'];
  6.         echo '</td>';
  7.    
  8.     echo '</tr>';
  9. }


y esto al final de la vista

Código PHP:
Ver original
  1. <div id="footer">
  2. <?php
  3. $actual = $this->Paginator->counter(array('format' => '%page%'));
  4. $total = $this->Paginator->counter(array('format' => '%pages%'));
  5. for ($i=1;$i<=$total;$i++) {
  6.     if ($i==$actual) {
  7.         echo ' P&aacute;gina '.$i.' ';
  8.     } else {
  9.         echo $this->Paginator->link(' ['.$i.'] ', array('page' => $i));
  10.     }
  11. }
  12. echo $this->Paginator->counter(array('format' => ' Total de %count%, comenzando en el registro %start%, terminando en el %end%')) ?>
  13. </div>