End Date on Details page

2 posts by 1 authors in: Forums > CMS Builder
Last Post: November 6, 2015   (RSS)

By Zicky - November 6, 2015

So this is probably a really simply solution, but I'm stumped on it. 

I need to add some code so that once a record has reached it's 'end_date' then the details page either produces no results and says something linking "Bidding Has Ended", hides the content of the page, or redirects the page. I know how to add an end_date to the 'where' on a multi-list page, but on a details page I haven't got a clue.

Below is my code:

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



<h1><?php echo htmlspecialchars($bidding_opportunitiesRecord['title']); ?></h1>
<?php echo $bidding_opportunitiesRecord['content']; ?>

Here's the 'where' line of code I'm using on my multi-list page so you can see what I have going on there.

'where'    =>   "(end_date >= NOW() OR end_date='0000-00-00 00:00:00')",

Any suggestions?

Thanks, Zicky