SHOWING A CLICKABLE PAGE COUNT ON A PAGE ALONG WITH THE PREV & NEXT LINKS - Aug 2nd, 2010


User Equinox69 noted that the default CMSB code produces this at the bottom of the pages:



<< prev - page 1 of 5 - next >>



He asked, “How can I make it offer a clickable page number, like:



<< prev - page 1 of 5 - next >> go to page #__



or



<< prev - page 1 - next >> 1, 2, 3, 4, 5



so that the end users can click to the page they want or enter in the page number they want?”

Damon from Interactive Tools answered with:

Here is some code to generate this type of pagination:



<< prev 1 2 3 4 next >>



Just change $your_table to your actual table name



<!-- START PAGINATION CODE -->
<?php if ($your_tableMetaData['prevPage']): ?>
<a href="<?php echo $your_tableMetaData['prevPageLink'] ?>">&lt;&lt; prev</a>
<?php else: ?>
&lt;&lt; prev
<?php endif ?>

<?php
if (@!$_GET['page']): $current_page = "1";
else:
$current_page = $_GET['page'];
endif;
?>

<?php foreach (range(1,$your_tableMetaData['totalPages']) as $page): ?>
<?php if ($page == $current_page): ?>
<strong><?php echo $page; ?></strong>
<?php else: ?>
<a href="?page=<?php echo $page; ?>"><?php echo $page; ?></a>
<?php endif ?>
<?php endforeach; ?>

<?php if ($your_tableMetaData['nextPage']): ?>
<a href="<?php echo $your_tableMetaData['nextPageLink'] ?>">next &gt;&gt;</a>
<?php else: ?>
next &gt;&gt;
<?php endif ?>
<!-- /END PAGINATION CODE -->





The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service