Printing a list of 'hidden' records

8 posts by 3 authors in: Forums > CMS Builder
Last Post: December 15, 2008   (RSS)

Hi all,

I’ve been asked to create a list of members for an organization client, but here’s the catch.

If a member is delinquent in their payments for more than 60 days then their record is (manually) hidden in the membership list by a “hidden” check box field.

The treasurer would like a list of these long past due members as part of a payment status list.

It seems that if a record is “hidden” then it is not included in a list page viewer no matter what the criteria.
<?php if ($record['hidden'] == '0'): ?> or <?php if ($record['hidden'] == '1'): ?>

So the following doesn’t work:

<table width="100%" valign="top" border="0">


<?php foreach ($artistsRecords as $record ): ?>
<tr>
<td >
<?php if ($record['hidden'] == '0'): ?>
<?php echo $record['last_name'] ?>, <?php echo $record['first_name'] ?><br />
<?php echo $record['email'] ?><br />
</td>
</tr>
<?php endif ?><?php endforeach; ?>
</table>

If the value is "0" then I get a list of all the unhidden records and if the value is "1" then there are no records shown.

Any suggestions on how to achieve the desired result?

Thanks

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Printing a list of 'hidden' records

By Dave - December 11, 2008

Jerry,

Try adding these options:

'where' => " 0 ",
'orWhere' => " hidden = '1' ",

The "orWhere" adds another condition that if matched will return a record even if it doesn't match any other conditions. Note that this might not work properly with automatic searching, etc.

To see the actual MySQL query that CMS Builder is using add this:
'debugSql' => true,

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Printing a list of 'hidden' records

By gkornbluth - December 12, 2008 - edited: December 12, 2008

Thanks Dave.

Hate to seem dumb. but it's been a really long day.

Where should I insert those lines in my code above?

Or do they appear at the top of the page in the "require once" section?

Thanks.

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Printing a list of 'hidden' records

By Dave - December 14, 2008

In the getRecord() block. You'll see some code like this:

list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'perPage' => '8',
));


But you may have different options or values. Add the lines in red:

list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'perPage' => '8',
'where' => " 0 ",
'orWhere' => " hidden = '1' ",

));


If that doesn't work post that little block of code from your viewer file and I'll take a look.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Printing a list of 'hidden' records

Thanks for the direction, Dave,

What actually worked for me was:

list($artistsRecords, $artistsMetaData) = etRecords(array(
'tableName' => 'artists',

'where' => " hidden = '0' ",
'orWhere' => " hidden = '1' ",

));

Then I could use:
<?php if ($record['hidden'] == '1'): ?> or
<?php if ($record['hidden'] == '0'): ?>
to show lists of each category of members on the same viewer page.

Just 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?

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Printing a list of 'hidden' records

By Dave - December 15, 2008

Glad it's working! :)

>Just 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?

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. :)

Hope that makes sense, let me know if you have any other questions about that.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Printing a list of 'hidden' records

Ah Ha...

Thanks
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php