Next record on detail page

4 posts by 3 authors in: Forums > CMS Builder
Last Post: January 6, 2011   (RSS)

By rjbathgate - June 21, 2010

Hello,

Is there an easy way / prebuilt something or other to link to the Next (and Previous) records on a DETAIL page.

The perPage option isn't an option as it's on a detail page, so was wondering if there is a "Next record" & "previous record" method?

I can't user num + 1 / num - 1 as that doesn't take into account record deletions.

Cheers
Rob

Re: [rjbathgate] Next record on detail page

By zip222 - June 22, 2010 - edited: June 22, 2010

yes there is. i use this all the time:

Add this to your header (update the tablename with yours):
list($prevRecord, $nextRecord, $firstRecord, $lastRecord) = getPrevAndNextRecords(array(
'tableName' => 'TABLENAME',
'recordNum' => getNumberFromEndOfUrl(),
));


And now you will have access to the following:

The various links (if they exist):
<?php echo $prevRecord['_link'] ?>
<?php echo $nextRecord['_link'] ?>
<?php echo $lastRecord['_link'] ?>
<?php echo $firstRecord['_link'] ?>


You also have access to the other fields (if they exist), for example:
<?php echo $prevRecord['title'] ?>
<?php echo $nextRecord['title'] ?>
<?php echo $lastRecord['title'] ?>
<?php echo $firstRecord['title'] ?>

Re: [zip222] Next record on detail page

By rjbathgate - June 22, 2010

Sweet worked a treat, thanks