Is there a way to set Expression Engine entries to be viewable by Su开发者_JAVA技巧per Admins but prevent everyone else from seeing it?
Thanks
It depends on how you have things set up.
You can set templates to only be viewable by super admins, so you could handle this at that level.
Or in the channel entries tag itself, you could set the status parameter depending on whether someone is a super admin and then use a certain status for the restricted entries (which could be closed if you like, or a custom status). Or you could do the same thing with categories instead if you prefer.
The following conditional is true for super admins (more info at http://expressionengine.com/user_guide/templates/globals/conditionals.html#cond_group_id)
{if group_id == '1'}
Using conditions within a channel entries tag can be a bit iffy - it depends on parse order - something like this could work:
{exp:channel:entries status='open{if group_id == "1"}|restricted{/if}' ....}
You can also just output certain stuff within a channel entries loop if the viewer is a super admin, but you need to use {if member_group == '1'} inside the loop instead.
This doesn't work for me, I've found that I can use the dynamic parameters feature of the channel:entries tag pair though to achieve the desired result:
http://expressionengine.com/user_guide/modules/channel/dynamic_parameters.html
:)
精彩评论