by
KK » Fri Feb 17, 2012 7:52 pm
Hey @webecho and @cheesypoof,
I gave this matter a little thought afterwards and, as it happens, there is currently a way to make this happen after all.
Once again the editable region type 'message' to the rescue (it appears 'message' was a misnomer

)
Here is what we can do -
Create a 'group' region and then place all the editable regions that you want to be hidden from your clients within this group. For our example I'll assume the name of this group is 'my_group'.
That done, add a region of type 'message' to the template this way -
- Code: Select all
<cms:editable name='my_js' type='message' dynamic='default_data'>
hide.html
</cms:editable>
We are effectively making this region dynamically execute an embedded snippet named 'hide.html' every time the admin page is loaded.
( please see
viewtopic.php?f=4&t=5095 for the basic idea).
Next create this 'hide.html' file and place it in your 'couch/snippets' folder.
Place the following content in the file -
- Code: Select all
<cms:if k_user_access_level lt '10' >
<script type="text/javascript">
//<![CDATA[
window.addEvent('domready',
function(){
$('f_my_group').setStyle('display', 'none');
}
);
//]]>
</script>
</cms:if>
This snippet gets executed every time the edit panel is displayed. You can place any regular Couch code here.
The code we have placed does this -
it checks the access level of the logged-in user. If it is less than '10' the user is not a super-admin (
http://www.couchcms.com/docs/concepts/users.html).
In which case it outputs some JavaScript that simply hides the group that holds the secret regions.
Please note that the name of our group, as we assumed, is 'my_group' and the id that Couch gives it has a 'f_' prefixed to it to make it 'f_my_group' (use Firebug to get the id if in doubt).
Till the time we support this 'hiding' facility natively, this hack should do the trick.
Please let me know if it helped.
Thanks.