PAGINATION limit

3 posts by 2 authors in: Forums > CMS Builder
Last Post: February 12, 2010   (RSS)

How to perform a limit number of pages, pagination number limit. I have article: http://goo.gl/sBRQ and numbers of other pages from this category. < 1 2 3 4 5 6 > over 8 is too much. I would like to see max 7 pages. I used this code for pagination: forum link http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/gforum.cgi?post=77539;search_string=next%20page;t=search_engine#77539

Thanks for help.

Re: [esteban] PAGINATION limit

By Chris - February 12, 2010

Hi esteban,

A lot of websites will only show you a certain number of pages in both directions from the current page (e.g. if you are on page 7, you might see 4,5,6,[7],8,9,10). This still allows users to navigate all the pages, but doesn't overwhelm them with too many numbers. Is this what you want to do?

If so, try replacing this line:

<?php foreach (range(1,$newsMetaData['totalPages']) as $page): ?>

with this:

<?php
$startNumber = max($current_page - 3, 1);
$endNumber = min($current_page + 3, $newsMetaData['totalPages']);
?>

<?php foreach (range($startNumber,$endNumber) as $page): ?>


I hope this helps! Please let me know if you have any questions or if this doesn't address your issue.
All the best,
Chris