phpzend-frameworkzend-paginator

How to limit the number of pagination links in Zend_Paginator


When using Zend_Paginator, I don't want it to show me all the pagination links. Here's how I am implementing it:

  $adapter = new Zend_Paginator_Adapter_DbSelect($result);
  $paginator = new Zend_Paginator($adapter);
  $page=$this->_getParam('page',1);
  $paginator->setItemCountPerPage(10);
  $paginator->setCurrentPageNumber($page);
  $this->view->paginator=$paginator;

Now it is showing me all the links. E.g. there are 100 records and 10 rows per page, so it will show me 1 to 10 links. How can I have 5 links, 1 to 5? Like this:

"start"  "previous" 1  2  3  4  5  "Next"  "End"

EDITED

<!--Number page links-->
<?php foreach ($this->pagesInRange as $page): ?>
    <?php if ($page != $this->current): ?>
        <a href="<?= $this->url(array('page' => $page)); ?>">
            <span class="fg-button ui-button ui-state-default"><?= $page; ?></span>
        </a>
        <?php else: ?>
            <span class="fg-button ui-button ui-state-default ui-state-disabled" ><?= $page; ?></span>
        <?php endif; ?>
    <?php endforeach; ?>

How can I change it so that it shows me only 5 links?

$adapter = new Zend_Paginator_Adapter_DbSelect($select);
$paginator = new Zend_Paginator($adapter);

$page=$this->_getParam('page',1);
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(5);
$this->view->paginator=$paginator;

Solution

  •  <!-- Numbered page links -->
        <?php foreach ($this->pagesInRange as $page): ?>
            <?php if ($page != $this->current): ?>
            <?php if ($page <6): ?>
                <a href="<?= $this->url(array('page' => $page)); ?>"><span class="fg-button ui-button ui-state-default"><?= $page; ?></span></a>
            <?php elseif($page <6): ?>
                <span class="fg-button ui-button ui-state-default ui-state-disabled" ><?= $page; ?></span>
            <?php endif; ?>
            <?php endif; ?>
        <?php endforeach; ?>