title: How to write Pagination logic?
body: <p>Can anyone provide some idea/logic to write the pagination logic for the search page i am working on? 
  The information i have is <strong>total number of pages</strong> for that search- <strong>10 records per page</strong> also i am been sent the both the previous and next page number(no problem writing the logic all i need to do i pull that info and populate. I am also getting the info which page i am on. I can only display 10 pages like below</p>
  
  <pre><code>&lt;previous 1 |2 |3 | 4| 5 | 6 | 7 | 8 | 9 | 10 next&gt;
  </code></pre>
  
  <p>Say if total pages are 15 and when user click next then i need to display like this</p>
  
  <pre><code>&lt;previous 2 |3 |4 |5 |6 |7 |8 |9 |10 |11 next&gt;
  </code></pre>
  
  <p>At any time i just need to show then 10 pages in the pagination. </p>
  
  <pre><code> #set($start = 1)
   #set($end = $Integer.parseInt($searchTO.getPagination().getNumberofPages()))
   #set($range = [$start..$end])
  
  #set($iter = 1)
              #foreach($i in $range)
                #foreach($link in $searchTO.getPagination().getDirectPageLinks())
                      #if($i == $iter)
                          #if ($Integer.parseInt($searchTO.getPagination().getPageNumber())==$iter)
                              &lt;a class="search_current" href="/?_page=SEARCH&amp;_action=SEARCH$link"&gt;$i &amp;nbsp|&lt;/a&gt;
                          #else
                              &lt;a href="/?_page=SEARCH&amp;_action=SEARCH$link"&gt;$i &amp;nbsp|&lt;/a&gt;
                          #end
                          #set($iter = 1)
                          #break
                      #else
                          #set($iter=$iter+1)
                      #end
  
                   #end
  
              #end
  </code></pre>