Ver Mensaje Individual
  #21 (permalink)  
Antiguo 15/02/2012, 21:26
Avatar de andresdzphp
andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 9 meses
Puntos: 793
Respuesta: Paginator Zend Framework 2.0 beta

Controlador

Código PHP:
Ver original
  1. public function indexAction()
  2.     {
  3.         $data = $this->albumTable->fetchAll();
  4.  
  5.         $view = new PhpRenderer();
  6.         $view->resolver()->addPath(__DIR__ . '/../../../views/paginator');
  7.  
  8.         PaginationControl::setDefaultViewPartial('items.phtml');
  9.        
  10.         $paginator = Paginator::factory($data);
  11.         $paginator->setDefaultItemCountPerPage(5);
  12.         $paginator->setView($view);
  13.        
  14.         $paginator->setCurrentPageNumber($this->request->query()->get('page', 1));
  15.        
  16.         return array(
  17.             'albums' => $paginator
  18.         );
  19.     }

la vista:

Código PHP:
Ver original
  1. <?php if ($this->pageCount): ?>
  2. <div class="paginationControl">
  3. <?php echo $this->firstItemNumber; ?> - <?php echo $this->lastItemNumber; ?>
  4.  of <?php echo $this->totalItemCount; ?>
  5.  
  6. <!-- First page link -->
  7. <?php if (isset($this->previous)): ?>
  8.   <a href="<?php echo $this->url('default', array('page' => $this->first)); ?>">
  9.     First
  10.   </a> |
  11. <?php else: ?>
  12.   <span class="disabled">First</span> |
  13. <?php endif; ?>
  14.  
  15. <!-- Previous page link -->
  16. <?php if (isset($this->previous)): ?>
  17.   <a href="<?php echo $this->url('default', array('page' => $this->previous)); ?>">
  18.     &lt; Previous
  19.   </a> |
  20. <?php else: ?>
  21.   <span class="disabled">&lt; Previous</span> |
  22. <?php endif; ?>
  23.  
  24. <!-- Next page link -->
  25. <?php if (isset($this->next)): ?>
  26.   <a href="<?php echo $this->url('default', array('page' => $this->next)); ?>">
  27.     Next &gt;
  28.   </a> |
  29. <?php else: ?>
  30.   <span class="disabled">Next &gt;</span> |
  31. <?php endif; ?>
  32.  
  33. <!-- Last page link -->
  34. <?php if (isset($this->next)): ?>
  35.   <a href="<?php echo $this->url('default', array('page' => $this->last)); ?>">
  36.     Last
  37.   </a>
  38. <?php else: ?>
  39.   <span class="disabled">Last</span>
  40. <?php endif; ?>
  41.  
  42. </div>
  43. <?php endif; ?>

Edit: Todo el problema debe ser relacionado con esto:

Cita:
Warning: No RouteStack instance provided
Y en lo demás ya no le hice cambios (es lo mismo del tutorial), quedó sin mostrar enlaces.
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP

Última edición por andresdzphp; 15/02/2012 a las 22:06