Though this question has been asked several times but I really couldn’t find any clue from it.
I am working on a client project in which the page numbers are generated like this:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] and so on …
So if there are 100 pages, these numbers will count to … [100].
Here is the code that I am using:
{foreach var=$page from=$pages counter=$counter}
<li><a href="$page.page_url">$counter</a>
{/foreach}
I am looking to paginate them such that at most only 10 pages numbers are displayed per page.
Any help will be highly appreciate.
Thanks in advance.
First you have to remember page number of the current page. Then decide about the behavior of the pagination. Example current page, next four pages, three previous pages, first page and last page
So for page nr 9 it looks like this:
[1] … [6] [7] [8] [bold 9] [10] [11] [12] [13] … [100]
Next (hardest) thing is defining an efficient algorithm.
For example:
Iteration example: