detailpages issue

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

By kovali - March 13, 2012


I have a listpage of available items, and each item has a link to the detailpage of the item. On the detailpage I would like to have a prev/next link to the detailpages of all other items... is this possible pls ?


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.


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

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


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

Hire me! Save time by getting our experts to help with your project.