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

Re: [kovali] detailpages issue

By Jason - March 13, 2012

Hi Koen,

Yes, this can be done. First, what you need to do is on your detail page, have a getRecords call that will return all records. Use the same call that you used on your list page so that ordering stays the same. (NOTE, don't use perPage on the detail page call). In this example, we store these records in a variable called $allRecords.

What you do then is go through the entire list looking for the record you are going to the record you are outputting on the page (in this case called $record). Once you find it, you can attempt to get this record that comes before and after it.

EXAMPLE:

foreach ($allRecords as $index => $tmpRecord) {

if ($tmpRecord['num'] == $record['num']) { //current record found
$previousRecord = @$allRecords[$index-1];
$nextRecord = @$allRecords[$index+1];
break;
}

}


After this, you can check to see if $previousRecord and $nextRecord have a value. If they do, you can output a link to those pages.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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