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 ross - December 11, 2008 - edited: December 11, 2008

Hi Jerry

Thanks for posting!

Your code looks good to me. I did a little test install internally here and used basically the same thing (different field name) and it works for me.

My first though is that perhaps the value for hidden items isn't actually "1". Could you check in the section editor for what values are assigned?

Next, I would setup a test.php file just to try a few things out. Like, maybe just create a quick list that only displays the value of that field like this:

<?php foreach ($artistsRecords as $record ): ?>
<?php echo $record['hidden'] ?><br>
<?php endforeach; ?>

Of course, you'll need that bit of code for the top of the page too. But this page will just display the actual value in "hidden" for each record.

Could you give this all shot and let me know where it gets us?

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

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