Limiting Pagination to a certain number (range) of links.
Instead of the way I have it currently set up, I basically need a way to limit the page link output to a range of page numbers that is displayed. And, I need the "prev" arrow to only display when needed (similar to how I have the "next" arrow working).
I've also attached my page so you can see my other working version (without any limiting in place).
That helped a ton! Thank you very much!
That should set maxDisplayPage to be the lowest of those 2 values, so you should never go beyond the totalPages number.
Thank you! That took care of the issue with too many pages being displayed. I've made a few more modifications and I now have one last question to get this exactly where it needs to be.
Everything works perfectly, displaying a maximum of 5 page numbers (when needed). However, is there a way to set a minimum number of pages to display as well? This is because when you are within 5 pages of the total number of pages, displayed page numbers begin dropping out. So, for instance, if you have 22 pages, when on page 18, you see all 5 page numbers (18, 19, 20, 21, 22). However, when you move to page 19, you now only see 4 page numbers (19, 20, 21, 22). This continues until, on page 22, it only displays its own number. However, on all those 5 final pages, all five page numbers should be visible (18, 19, 20, 21, 22).
Hello all! I just wanted to report back and let you know that I figured out how to achieve the desired effect. I'm also posting the code below in case anyone tries to do this in the future.
Place in head section after loading viewer library (change information in red to match your CMSB configuration). For some reason, I found it necessary to duplicate this information below also.
Place in body section, wherever you want to include pagination.
Here's some code I'm using to achieve a similar effect. For mine, I always want to show the start and end numbers. I also have a prev/next links if they apply. Finally, you can control how many numbers show in the middle.
Where you want the pagination code to be shown. Change the numbers in red to control how many additional numbers you see on either side of the current page.
Ooooh... that's clean. Very nice! Thanks so much for sharing Kevin!
P.S. In case anyone refers to this later, I made some improvements to my version. (Though Kevin's is much more concise and is definitely worth looking at.) But, in my newer version, I fixed a few bugs and I added the ability to automatically remove "..." when appropriate. The most important improvement was that I added the ability for pagination to work even when the list is being filtered by category, date, or tags (just ensure you change the field names as needed). This makes it much more versatile. Of course, if you're not using any of those filters, they are just ignored.