This very handy plugin was written by Chris from Interactive Tools allows customization of which fields appear in an editor depending on the current user's 'skill_level' field.
The first thing that you'll need to implement this plugin is a new single value pull down list field in the User Accounts (accounts) editor called skill_level. You can name it anything that suites your application because you'll reference that field in the plugin.
Decide on the skill levels you'll need for your application and enter them as the values to be chosen from the pull down list for each user account.
For this example there are 2 skill levels, Beginner and Expert.
If you want to manage the fields in a section called "my_section" you'll want to have a list of the field names in that section handy.
Let's assume you've got 4 fields named beginner_field_1, beginner_field_2. expert_field_1, and expert_field_2
Next open the plugin and insert the name of your skill level field in the code:
$GLOBALS['BETA_USER_SKILL_FIELDS_SKILL_FIELD_NAME'] = 'skill_level';
In in the code below, (remember, my_section refers to the section where you want to show or hide fields), both expert fields will be hidden from any user whose skill_level is "Beginner". You can add as many skill levels as you like, but the last one has no trailing comma.
$GLOBALS['BETA_USER_SKILL_FIELDS_CONFIG']['my_section'] = array( // user's skill values and lists of fields to hide 'Beginner' => array('expert_field_1', 'expert_field_2'), 'Expert' => array() );
Repeat this code block as many times as necessary and replace "my_section" with the name of the editor that you want to affect.
PULLING ARRAY VALUES FROM ANOTHER EDITOR Here's where the fun begins. Set up this plugin so that your clients can change the hidden fields for the various skill levels without needing to dive into the back end of CMSB and mucking up the works.
Here's how:
THE NEW EDITOR Create a single record editor with a multi-value check box list field for each skill level you'll need to control. beginner_hide and expert_hide are used for this example.
Insert the field names in the table you want to show or hide as the option values for the lists. Note: Don't forget that you can use field names followed by the "pipe" character "|" followed by a user friendly name to make your list options more readable. Like this:
my_first_field_name_with_lots_of_complex_characters|The Simple Name
Check some boxes and save the record
MODIFY THE PLUGIN CAVEAT: Remember nothing can precede the"Plugin Name" through "Requires at least" code block.
So, insert a:
?> <?php
after that code block:
<?php
?> <?php
Insert your load records calls in between the ?> and the <?php you just added, like this:
<?php
?> <?php require_once "/path_to_your/cmsAdmin/lib/viewer_functions.php"; // load records list($your_list_tableRecords, $your_list_tableMetaData) = getRecords(array( 'tableName' => 'your_list_table', 'allowSearch' => false, 'limit' => '1', )); $your_list_tableRecord = @$your_list_tableRecords[0]; // get first record
?>
Instead of the code:
'Beginner' => array('expert_field_1', 'expert_field_2'), 'Expert' => array()
Insert the code:
'Beginner' => explode("\t", trim($your_list_tableRecord['beginner_hide'], "\t")), 'Expert' => explode("\t", trim($your_list_tableRecord['expert_hide'], "\t"))
This will populate your arrays with the checked values in each of the check box fields.
You can add as many arrays as you need to, but remember the last one has no trailing comma Your modified code should look something like this:
<?php
?> <?php require_once "/path_to_your/cmsAdmin/lib/viewer_functions.php"; // load records list($your_list_tableRecords, $your_list_tableMetaData) = getRecords(array( 'tableName' => 'your_list_table', 'allowSearch' => false, 'limit' => '1', )); $your_list_tableRecord = @$your_list_tableRecords[0]; // get first record
?> <?php
// CAVEATS: // - it is not currently possible to hide Separator fields.
// UPDATE THESE VALUES
$GLOBALS['BETA_USER_SKILL_FIELDS_SKILL_FIELD_NAME'] = 'skill_level'; // For each section, copy this block $GLOBALS['BETA_USER_SKILL_FIELDS_CONFIG']['my_section'] = array( // user's skill values and lists of fields to hide 'Beginner' => explode("\t", trim($your_list_tableRecord['beginner_hide'], "\t")), 'Expert' => explode("\t", trim($your_list_tableRecord['expert_hide'], "\t")) );
// DON'T UPDATE ANYTHING BELOW THIS LINE
**IMPORTANT**: Changing the values in the arrays MAY NOT affect any existing records, so you'll need to test by creating NEW records to see which fields are actually hidden or shown.
To see what values are actually being inserted into your arrays, you can add:
showme($GLOBALS['BETA_USER_SKILL_FIELDS_CONFIG']['master_subscription_pages']);
Just above the // DON'T UPDATE ANYTHING BELOW THIS LINE
And when you log into your CMSB admin Interface you'll see the array values superimposed over your interface. View the source of that page and you'll see the values much more clearly.
When you're done, remove or comment out the showme line with double slashes (//), or your users will see the superimposed values as well.
HIDING SEPARATORS Instead of using standard separators, use HTML separators with code like these examples (the ID name of the separator is copied from your field list)
Red Headline Text
<tr> <td colspan='2'> <div class="content-box content-box-divider" name="__separator017__"> <div class="content-box-header"><h3><font color="red">YOUR MENU INFORMATION</font></h3></div> </div> </td> </tr>
or explanatory text inside a box
<tr> <td colspan='2'> <div class="content-box content-box-divider" name="__separator016__">Your explanatory text goes here.<br /> <br /></div> </td> </tr>
Or explanatory text without a box
<tr>
<td colspan='2'><div name="__separator015__"><font color="red">IMPORTANT:</font> Your explanatory text goes here. <br /> <br /></div> </td> </tr>
Then include each separator names in your field name list
__separator015__|Explanatory text __separator017__|The Menu
|