SHOWING HIDDEN RECORDS IN A VIEWER - Aug 2nd, 2010


If you need to show a list of the records that have been hidden using the special ‘hidden’ field, you’ll need to
put a set of ‘where’ statements in the getrecords() block at the top of your viewer page.



list($artistsRecords, $artistsMetaData) = getRecords(array(
'Table name' => 'artists',
// Insert This Code
'where' => " hidden = '0' ",
'orWhere' => " hidden = '1' ",
));
// End of Insert



Then you can use the ‘if’ statements:



<?PHP if ($record['hidden'] == '1'): ?> and <?PHP if ($record['hidden'] == '0'): ?>

after your ‘foreach ‘statements to show the records that match either criteria, like this:

<?PHP foreach ($artistsRecords as $record ): ?>
<?PHP if ($record['hidden'] == '1'): ?>
<?PHP echo $record['last_name'] ?>, <?PHP echo $record['first_name'] ?>
<?PHP endif ?>
<?PHP endforeach; ?>



I was curious, why is it necessary to use the 'where' statements in the getRecord() block for the "hidden"
field and not necessary for any regular fields?

According to Dave Edis from Interactive Tools:
The "hidden" field is a special field. Anytime it exists CMS Builder automatically adds "WHERE hidden = 0" to the query.
You can see the MySQL query CMS Builder creates by temporarily adding this option below the others:


'debugSql' => true,



You can see a list of other "special" fieldnames here:

http://www.interactivetools.com/docs/cmsbuilder/special_fieldnames.html

Since the purpose and design of the “hidden” field is to hide those records, when you want to show them instead we
need to do some extra work to make it work. :)

Thanks Dave, it makes sense now



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service