<< 1 2 3 4 … 15 16 17 … 47 48 49 50 >>
<< 1 2 3 4 5 6 7 … 47 48 49 50 >>
<< 1 2 3 4 … 44 45 46 47 48 49 50 >>
(the bold is the selected page)
Is there any cleaver logic out there that creates scaling pagination like this? I have created one of these before but it ended up as a mess of logic statements.
The language i am doing this in now is PHP but if you have examples or tips for any language, it would be appreciated.
By scaling i mean when there are only a few pages. The pagination displays this.
<< 1 2 3 4 5 6 7 >>
As the number of pages grow to a certain point, the pagination stops showing all numbers and starts splitting them up.
<< 1 2 3 4 … 47 48 49 50 >>
<< 1 2 3 4 5 6 … 47 48 49 50 >>
<< 1 2 3 4 5 6 7 8 … 47 48 49 50 >>
<< 1 2 3 4 .. 7 8 9 … 47 48 49 50 >>
<< 1 2 3 4 .. 15 16 17 … 47 48 49 50 >>
<< 1 2 3 4 … 44 45 46 47 48 49 50 >>
<< 1 2 3 4 … 47 48 49 50 >>
(note, the actual numbers and how many it shows before and after is not relevant)
Sorry for the blob of code but here goes. Hopefully the comments are enough to tell you how it works – if leave a comment and I might add some more.