Tuesday, April 12, 2011

Hiding the Ribbon for Anonymous Users

Ribbon is a great new feature introduced by SharePoint 2010. It provides great user experience for users with elevated privileges, like contributors and site owners. However, for users with lease privilege, such as visitors and anonymous users, it seems like a big waste of page real estate. Because for those users, all ribbon provides are navigation breadcrumb and welcome control (user name with a drop down list on top-right corner).

So I have been asked to figure out a way to remove or hide the ribbon area from user with lease privilege, and here is how:


1. Open your SharePoint master page




<div id="signinlink"><a href="/_layouts/authenticate.aspx">User Login</a></div>

<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="ManageLists">
  Put Your Control Here ... such as ...
  <div id="s4-ribbonrow" class="s4-pr s4-ribbonrowhidetitle">
  ..........
  </div>

<style>
#signinlink{display:none;}
</style>
</SharePoint:SPSecurityTrimmedControl>

2. Save and publish master page


OR



<div class="signinlink">
<a href="/_layouts/authenticate.aspx">User Login</a>
<a href="/_layouts/signout.aspx" class="signout">Sign Out</a>

</div>

    <asp:LoginView runat="server">
    <AnonymousTemplate>
        <style type="text/css">
            #s4-ribbonrow { display: none; }
        </style>
    </AnonymousTemplate>
    <LoggedInTemplate>
    <style type="text/css">
            .signinlink { display: none; }
            .signout { display: block; }
      </style>
    </LoggedInTemplate>
</asp:LoginView>


Class in style.CSS
.signinlink
{
color:#093762 !important;
font:12px Arial;
font-weight:bold;
text-decoration:none;
padding-top:20px;
}
.signout
{
color:#093762 !important;
font:12px Arial;
font-weight:bold;
text-decoration:none;
display:none;
}

No comments:

Post a Comment