Show Record if Active

3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 29, 2009   (RSS)

By theclicklab - December 28, 2009

Hi there, I have a field for if the page is active and have included this in the head:

list($aboutRecords, $aboutMetaData) = getRecords(array(
'tableName' => 'about',
'where' => whereRecordNumberInUrl(1),
'where' => 'active ="1"',
'limit' => '1',
));


But my problem is that I only get the first record back for all pages. If I remove:

'where' => 'active ="1"',

Everything works fine. Any suggestions on how to make this work correctly?

Many thanks!

Re: [aquaman] Show Record if Active

By Chris - December 29, 2009

Hi aquaman,

Presumably you are using this on a detail page? If you want to restrict things so that your page will only display records which are active, you can add to the where clause like this:

list($aboutRecords, $aboutMetaData) = getRecords(array(
'tableName' => 'about',
'where' => whereRecordNumberInUrl(1) . ' AND active ="1"',
'limit' => '1',
));


With this setup, a visitor who tries to view the detail page of a record which is not active will likely get a "Record not found!" message or an error, depending on the rest of your code. If you want something else to happen instead, please let me know and I'll show you how to add some logic for that.

I hope this helps. Please let me know if you have any questions.
All the best,
Chris