
Theo
Project Manager
/ Moderator

Nov 15, 2006, 12:15 PM
Post #10 of 12
(2016 views)
Shortcut
|
|
Re: [almas] Adding Tab in User Panel?
[In reply to]
|
Can't Post
|
|
Almas, I've come up with a way to hide fields in the Article Editor. I've done it by adding field separators that wrap the section in a hidden table if a user field value isn't matched. Some things to note: - Hiding WYSIWYG fields has an annoying side-effect: this strange loop is created somehow that calls the WYSIWYG's blank.gif file repeatedly. So with this system, I'd recommend not hiding WYSIWYGs (switch them to plain textareas) or else put up with the little hourglass that will flicker for a minute on your mouse when you add/edit an article. :) - Make sure you don't hide any required fields (such as Filename). Okay, it shouldn't be too hard if you go step-by-step. Here's how it's done: 1. Add User Fields to specify user access to the article fields.
Go to Admin > Database Editor and click "edit table and fields" for User Accounts. Click "Add Field". Set your field values as:
Field Label: News Contributer Field Name: newsContributer Field Type: checkbox Stored as: string Field Options/Description: The user can see the "News" specific fields. Then Save. Next, add another user field:
Field Label: XYZ Contributer Field Name: xyzContributer Field Type: checkbox Stored as: string Field Options/Description: The user can see the "XYZ" specific fields. Field Separator: set position to "after field" and the type to "blank line" Then save again. In the Table Editor page, set the "order" value for News Contributer to be "101" and for XYZ Contributer set it to "102". Then click the "go" button at the bottom of the page to "Update Field Order". This will put your new fields after the "Notes" box, above the notification fields. 2. Add code to hide the article fields from different users.
Go back to Admin > Database Editor and click "edit table and fields" for Articles. Click "Add Field". Field Label: Separator for News (begin) Field Name: beginNewsSeparator Field Type: none Field Separator: Select "html" and paste in the following code: <!-- templateIf : $currentUser.newsContributer$ ne "Yes" --> <tr><td colspan="2"> <table style="display: none;"> <!-- /templateIf --> Then save the field, and "Add Field" once again.
Field Label: Separator for News (end) Field Name: endNewsSeparator Field Type: none Field Separator: Select "html" and paste in the following code: <!-- templateIf : $currentUser.newsContributer$ ne "Yes" --> </table> </td></tr> <!-- /templateIf --> Save your new field. Then update the Field Order so that your "Begin" separator appears before the first News field, and the "End" separator appears after your last News field. Repeat to add separator fields for your XYZ Contributors as well (using the $currentUser.xyzContributer$ placeholder in your templateIf). 3. Update your users
Finally, you'll want to update any user accounts so that they can see the fields as appropriate (especially your Admins and Editors). Note that this new field needs to be set in addition to the Category Rights - there's no link between the two. And that's about it. I hope this helps. I've tested it out, so hopefully this will do the trick for you. Note that this could be useful in other situations as well. The templateIf could test any field, so instead of our custom fields you could restrict it by accessLevel or even user's name. Thanks, Almas. If you have any other questions, don't hesitate to ask! Theo Wiersma Project Manager
(This post was edited by Theo on Nov 15, 2006, 3:21 PM)
|