Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to limit the number of pagination links in Zend_Paginator
    text
    copied!<p>When using Zend_Paginator, I don't want it to show me all the pagination links. Here's how I am implementing it:</p> <pre><code> $adapter = new Zend_Paginator_Adapter_DbSelect($result); $paginator = new Zend_Paginator($adapter); $page=$this-&gt;_getParam('page',1); $paginator-&gt;setItemCountPerPage(10); $paginator-&gt;setCurrentPageNumber($page); $this-&gt;view-&gt;paginator=$paginator; </code></pre> <p>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. <strong>How can I have 5 links, 1 to 5?</strong> Like this:</p> <pre><code>"start" "previous" 1 2 3 4 5 "Next" "End" </code></pre> <p><strong>EDITED</strong></p> <pre><code>&lt;!--Number page links--&gt; &lt;?php foreach ($this-&gt;pagesInRange as $page): ?&gt; &lt;?php if ($page != $this-&gt;current): ?&gt; &lt;a href="&lt;?= $this-&gt;url(array('page' =&gt; $page)); ?&gt;"&gt; &lt;span class="fg-button ui-button ui-state-default"&gt;&lt;?= $page; ?&gt;&lt;/span&gt; &lt;/a&gt; &lt;?php else: ?&gt; &lt;span class="fg-button ui-button ui-state-default ui-state-disabled" &gt;&lt;?= $page; ?&gt;&lt;/span&gt; &lt;?php endif; ?&gt; &lt;?php endforeach; ?&gt; </code></pre> <p>How can I change it so that it shows me only 5 links?</p> <pre><code>$adapter = new Zend_Paginator_Adapter_DbSelect($select); $paginator = new Zend_Paginator($adapter); $page=$this-&gt;_getParam('page',1); $paginator-&gt;setItemCountPerPage(10); $paginator-&gt;setCurrentPageNumber($page); $paginator-&gt;setPageRange(5); $this-&gt;view-&gt;paginator=$paginator; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload