Search code examples
phpzend-frameworkzend-paginator

Zend_Paginator reversed order


I have a question about the Zend_Paginator. By default pages goes like:

<Previous 1 2 3 4 5 6 7 8 ... Next>

Is this possible to have order like

<Previous 8 7 6 5 4 3 2 ... Next>


Solution

  • No need to mess with the paginator class, you control how the pages are displayed with your paginator control script.

    In your control script you will find a code like:

    <!--Number page links-->
     <td>|
          <?php foreach ($this->pagesInRange as $page):?>
                <?php if ($page != $this->current) :?>
                      <a href="<?php echo $this->url(array_merge($params, array('page' => $page)))?>">
                      <?php echo $page?></a> |
                <?php else:?>
                      <?php echo $page?> |
           <?php
                 endif;
                 endforeach;
           ?>
     </td>
    

    This is where you can reverse the order of the pages if you choose. Just use normal PHP array functions to get the page order you desire.