Pagination - Show Min/Max Page Numbers

2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 17, 2014   (RSS)

By claire - July 17, 2014

Hey Perch

You've already got the total pages there - $productsMetaData['totalPages']. That's your final number. Just add this to your code:

<?php echo $startNumber < 7 ? '' : '<li><a href="'.$settings['indexPage'].'?p='.$selectedPage['num'].'">1</a>...</li>'; ?>
<?php foreach (range($startNumber,$endNumber) as $paginate): ?>
  <?php if ($paginate == $current_page): ?>
    <li class="current"><a href="#"><?php echo $paginate; ?></a></li>
  <?php else: ?>
    <li><a href="<?php echo $settings['indexPage'] ?>?p=<?php echo $selectedPage['num'] ?>&page=<?php echo $paginate; ?>"><?php echo $paginate; ?></a></li>
  <?php endif ?>
<?php endforeach; ?>
<?php echo $endNumber < $current_page + 7 ? '' : '<li>...<a href="'.$settings['indexPage'].'?p='.$selectedPage['num'].'&page='.$endNumber.'">'.$endNumber.'</a></li>'; ?>

I think that should do it. Let me know if it works.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/