Incorrect records displaying on detail page

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 15, 2016   (RSS)

Hi superhappybunnycat,

This seems to be happening because the detail page has been setup to load the first record from the events section, but it needs to get the record based on the value in the URL. You need to update detail.php as follows:

  // load record from 'event'
  list($eventRecords, $eventMetaData) = getRecords(array(
    'tableName'   => 'event',
    'where        => whereRecordNumberInUrl(0),
    'limit'       => '1',
    'loadUploads' => true,
    'allowSearch' => false,
  ));
  $eventRecord = @$eventRecords[0]; // get first record
  if (!$eventRecord) { dieWith404("Record not found!"); } // show error message if no record found

So I've updated the where statement so that it uses the whereRecordNumberInUrl function, which gets the num value from the URL and creates a where statement for it. I've also added a limit so that only 1 record is returned at a time. 

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Perfect, thanks Greg!