p - is request parameter where the page number is given by user
<#assign totalPages =searchResult.getTotalPages()>
<#assign lastPage = 0>
<#list totalPages as curPage>
<#if p=curPage>
<a href="#" class="selected">${p}</a>
<#assign lastPage = curPage?number>
<#else>
<a href="/search.html?q=${q?html}&p=${curPage}">${curPage}</a>
</#if>
</#list>
This will print links like this
1 2 3 4 5 6 7 8 9 10 11 - and the list keeps going to the last page lets say 100
What I would like to accomplish is these cases (number in <x> is the p – page selected by user):
Case A:
1 <2> 3 4 5 ... 100
Case B:
1 ... 11 12 <13> 14 15 ... 100
Case C:
1 ... <96> 97 98 99 100
Here are two helper functions
maxandminand a macro I calledpages:This macro produces, when invoked with a sequence of page numbers and the current page, e.g.
the following output (removed some whitespaces):