Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
Hi, tried to find some documentation about this setting,
tried a dump and dump_all but no luck.
Saw there's a "$show_advanced_settings = 1;" inside file edit-pages.php
If you inspect the element or view the source of an admin panel page in your browser, you'll find that the Advanced Settings are in a div with id="advanced-settings". So you can hide that div by injecting css into a message-type editable tag. You can use couch tags to determine who can see them and who can't.
Code: Select all
    <cms:editable name='hide' type='message'>
       <!-- Only super admin can see Advanced Settings -->
       <cms:if k_user_access_level lt '10'>
           <style>#advanced-settings{display:none;}</style>
        </cms:if>
    </cms:editable>

This would be a simple template-based way to do what you're asking.
@tim, you are thinking on the right line. However, the way you are using the 'message' region will only literally inject the Couch tags inside the edit screen (i.e. will not execute those tags).

The correct implementation would be as follows -
Code: Select all
<cms:editable name='hide' type='message' dynamic='default_data'>
hide.html
</cms:editable>

You'll also need to create a snippet named 'hide.html' and place it in your couch/snippets folder.
Place the following within the snippet -
Code: Select all
<cms:if k_user_access_level lt '10' >
    <style>#advanced-settings{display:none;}</style>
</cms:if>

Now the contents of the message region are dynamic - every time the edit page is accessed, the region tries to find a snippet named 'hide.html', execute it and inject the content returned by the snippet in the admin-panel.

You can find this technique being used to conditionally inject JavaScript in the admin-panel -
viewtopic.php?p=7068#p7068

Hope it helps.
Thanks @KK. That's the first time I've seen the dynamic='default_data' parameter. I get the feeling there are a lot of undocumented but useful tidbits like that scattered around in Couch.

However, in my own testing it was unnecessary. The code as I wrote it worked as expected. The style tag and its contents are injected if and only if the cms:if condition is met. The Couch tags themselves are parsed normally, and not injected literally.

I only recently stumbled upon the idea of placing Couch tags inside the message region while experimenting, but it has always worked in my own testing. The Couch tags are executed as expected without any special handling.
@tim, I am not contending your observation but this is surprising for me.
To be honest, I can't see how that could work (actually, I tested it just now to double-check my assumptions).

Any chance you could allow me take a look at your setup?
I found it surprising, too, that my experience was at odds with what you were saying. If you tested it, too, then I'm really puzzled. Anyone want to take odds on it being me that's confused? :)

Give me a little time. I can't do it right now, but I'll set up an example and get you access.
This conversation continues in another thread.
viewtopic.php?f=2&t=9485
7 posts Page 1 of 1
cron