Hide Multiple Records

4 posts by 2 authors in: Forums > CMS Builder
Last Post: November 11, 2011   (RSS)

Re: [InHouse] Hide Multiple Records

By gkornbluth - November 11, 2011

Hi J,

There's a plugin that will specifically fit your needs called fieldResetter.

Here's the recipe from my CMSB Cookbook http://www.thecmsbcookbook.com that describes where to find it and how to use it.

RESET THE VALUE OF A FIELD IN ALL RECORDS OR IN FIELDS IN MULTIPLE TABLES (CHECK BOXES ONLY)

And here’s another useful plugin from Carl Crowder at Interactive Tools called fieldResetter. This one does exactly that. It resets the
all the values of one or more fields in one or more tables globally. I’m using it to reset a field in a membership database called
paid_for_current_year, which needs to be reset at the end of each year.

After implementing the plugin, you'll find the option to execute the global change in the "Advanced Commands" pull down menu at the bottom of the record list for that section editor.

You can download this plugin from:

http://www.thecmsbcookbook.com/downloads/fieldResetter.zip

Implementation is really simple.

If you want to globally reset the value of a checkbox field called “paid_for_current_year” to “0" in a table called “members”,
you’d adjust the array on line 15 to:

$GLOBALS['FIELD_RESET_FIELDS'] = array(
array('Table name' => 'members', 'fieldName' => 'paid_for_current_year', 'resetValue' => 0 ) );


If you have 2 fields to be reset, you’d adjust the array to:
$GLOBALS['FIELD_RESET_FIELDS'] = array(
array('Table name' => 'members', 'fieldName' => 'paid_for_current_year', 'resetValue' => 0 ),
array('Table name' => 'members', 'fieldName' => 'other_field', 'resetValue' => 0 ) );
);

For 2 tables:
$GLOBALS['FIELD_RESET_FIELDS'] = array(
array('Table name' => 'members', 'fieldName' => 'paid_for_current_year', 'resetValue' => 0 ),
array('Table name' => 'other_table', 'fieldName' => 'other_field', 'resetValue' => 0 ) );


Let’s say you wanted to give permission to accomplish this to a “Super Admin only, you could add a checkbox field to your Accounts
section called 'super_admin' and change the check on line 27 to
if ( !$CURRENT_USER['super_admin'] ) return;
If you make the “super_admin” field a system field, it will be harder to inadvertently change it’s value.

Enjoy,

Jerry Kornbluth
Head Chef
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] Hide Multiple Records

By InHouse - November 11, 2011

Perfect! Just the thing. Worked as billed.

Many thanks Jerry!

Re: [InHouse] Hide Multiple Records

By gkornbluth - November 11, 2011

You're welcome.

Glad it worked.

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