The idea is very simple really. Make usage of the SPSecurityTrimmedControl control, but instead of wrapping the whole Ribbon DIV inside it, hide the Ribbon DIV and wrap SPSecurityTrimmedControl around a small JavaScript that shows the Ribbon.
More technical how-to (slightly modified from the original post to fit my needs):
- Open SharePoint Designer and open your site and your Master Page.
- Locate:
<div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle"> - Change it to:
<div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle" style="display:none;"> - >
- Find the end tag of "s4-ribbonrow" and add following code after it:
<Sharepoint:SPSecurityTrimmedControl ID="spTrimRibbon"runat="server" PermissionMode="All" PermissionContext="CurrentSite" AuthenticationRestrictions="AuthenticatedUsersOnly">
<script type="text/javascript"> document.getElementById("s4-ribbonrow").style.display = "block";
</script>
</Sharepoint:SPSecurityTrimmedControl> - Save your work.
- That's it!
Now, this approach can be used to hide/show elements based on various rules, not just the Ribbon as illustrated in this post.
Hope you found this as useful as I did!
Thanks to Dr.Z for the original post.
Ingen kommentarer:
Legg inn en kommentar