go to Last page in a prev/next list

2 posts by 2 authors in: Forums > CMS Builder
Last Post: March 11, 2010   (RSS)

Re: [s2smedia] go to Last page in a prev/next list

By Chris - March 11, 2010

Hi s2smedia,

The simplest answer is:

<a href="?page=<?php echo $recordMetaData['totalPages'] ?>">last page</a>

where recordMetaData (in red above) is the name of your meta data variable you get from getRecords().

There are some more complicated setups which may require you to pass forward existing query string arguments. If this is the case, you can do:

<?php
$extraQueryArgs = '';
foreach ($_REQUEST as $key => $value) {
if ($key == 'page') { continue; } // skip page value, we set it below
if (is_array($value)) { continue; } // skip multi value php fields
$extraQueryArgs .= urlencode($key) .'='. urlencode($value) . '&amp;';
}
?>
<a href="?<?php echo $extraQueryArgs ?>page=<?php echo $recordMetaData['totalPages'] ?>">last page</a>


I hope this helps. Please let me know if you have any questions.
All the best,
Chris