4 posts by 2 authors in: Forums > CMS Builder
Last Post: April 14, 2014   (RSS)

By Chris - April 3, 2014

Hi Deborah,

The argument to whereRecordNumberInUrl() is the default where clause used if there is no number in the URL. whereRecordNumberInUrl(1) is the same as whereRecordNumberInUrl("TRUE"), it defaults to WHERE TRUE, so it will find the first record.

whereRecordNumberInUrl("FALSE") or whereRecordNumberInUrl(0) will not return a record if there is no number in the URL.

This should work:

---- HEAD ----
// 'news' list 
list($newsRecords, $newsMetaData) = getRecords(array( 
  'tableName' => 'news', 
  'orderBy' => "posting_date DESC", 
)); 
// category title for pg heading 
list($newsRecordsHDG, $newsMetaData) = getRecords(array( 
  'tableName' => 'news', 
  'limit' => '1', 
  'where' => whereRecordNumberInUrl("FALSE"), // if no record number in url, where = FALSE
  'allowSearch' => false,
));

---- HTML ----
<?php if ($newsRecordsHDG): ?>
  <?php foreach ($newsRecordsHDG as $record): ?><?php echo $record['category:label'] ?><?php endforeach ?>
<?php else: ?>
  News
<?php endif ?>

Does that help?

All the best,
Chris

By Deborah - April 13, 2014

Chris, I just realized I hadn't replied. Your solution worked perfectly!  I was always a bit mystified about the differences in use of whereRecordNumberInUrl(), so your explanation was also helpful.

Thanks so much for your time and expertise!
Deborah

By Chris - April 14, 2014

Hi Deborah,

Glad to be of help!

All the best,
Chris