Posted By

yanek1988 on 06/03/11


Tagged

zend


Versions (?)

Zend_Paginator


 / Published in: PHP
 

  1. // in Bootstrap
  2. Zend_Paginator::setDefaultScrollingStyle('Sliding');
  3. Zend_View_Helper_PaginationControl::setDefaultViewPartial(array(
  4. 'partials/pagination.phtml',
  5. 'default'
  6. ));
  7.  
  8. // in controller
  9. $this->view->paginator = new Zend_Paginator( new Zend_Paginator_Adapter_DbSelect($query) );
  10. $this->view->paginator->setItemCountPerPage( 15 );
  11. $this->view->paginator->setCurrentPageNumber( $this->getParam('page',1) );
  12. $this->view->paginator->setPageRange( 5 );
  13.  
  14. // partials/pagination.phtml
  15. <? if ($this->pageCount > 1){ ?>
  16. <div class="paginationControl">
  17. <? if (isset($this->previous)){ ?>
  18. <a href="<?=$this->url(array('page' => $this->previous))?>">&laquo;</a>
  19. <? } else { ?>
  20. <span class="disabled">&laquo;</span>
  21. <? } ?>
  22.  
  23. <? foreach ($this->pagesInRange as $page){ ?>
  24. <? if ($page != $this->current){ ?>
  25. <a href="<?=$this->url(array('page' => $page))?>"><?=$page?></a>
  26. <? } else { ?>
  27. <span><?=$page?></span>
  28. <? } ?>
  29. <? } ?>
  30.  
  31. <? if (isset($this->next)){ ?>
  32. <a href="<?=$this->url(array('page' => $this->next))?>">&raquo;</a>
  33. <? } else { ?>
  34. <span class="disabled rg">&raquo;</span>
  35. <? } ?>
  36. </div>
  37. <? } ?>
  38.  
  39. // in my-script.phtml
  40. <?=$this->paginator?>

Report this snippet  

You need to login to post a comment.