Tuesday, November 13, 2012

Hiding SharePoint Ribbon Control from users


Add this to the head section on master page.

<style type="text/css">
div#s4-ribbonrow {
display:none;
}
</style>

<Sharepoint:SPSecurityTrimmedControl runat="server"
Permissions="AddAndCustomizePages">
<style type="text/css">
div#s4-ribbonrow {
display:block;
}
</style>
</Sharepoint:SPSecurityTrimmedControl>



This should hide the ribbon control.


4 comments:

  1. Thank you very much for this code! It works very well and is easy to implement. Could the suiteBrandingBox, suiteLinksBox, suiteBarRight etc. in the ribbon (Newsfeed, Sky Drive, Sites)be hidden in the same manner? How would the code look?

    ReplyDelete
    Replies
    1. Wayne, check this post:
      http://www.tuyrcorp.com/sharepoint-2013-top-links-name-id-and-how-to-hide-them/

      Regards // Thomas

      Delete
  2. Hi Wayne,
    I havent tried that.It should be possible using jquery.

    ReplyDelete
  3. Hi Fahad.

    I'm trying to add the code that you post to a master page (mymaster.master) in SharePoint 2013 but it seems like .master files can not be edited. I'm using SharePoint Designer 2013. When I try to edit mymaster.master file and save it, I got this error: "This file may not be moved, deleted, renamed or otherwise edited". I have to edit the html file associated to mymaster.master, so I added in the mymaster.html file the following lines:

    <style type="text/css">
    div#s4-ribbonrow {
    display:none;
    }
    </style>

    <!--MS:<SharePoint:SPSecurityTrimmedControl runat="server" Permissions="AddAndCustomizePages">-->
    <style type="text/css">
    div#s4-ribbonrow {
    display:block;
    }
    </style>
    <!--ME:</SharePoint:SPSecurityTrimmedControl>-->

    When I publish the mymaster.html file, the change reflects in mymaster.master file. It looks like:

    <style type="text/css">//<![CDATA[
    div#s4-ribbonrow {
    display:none;
    }
    //]]></style>

    <SharePoint:SPSecurityTrimmedControl runat="server" Permissions="AddAndCustomizePages">
    <style type="text/css">//<![CDATA[
    div#s4-ribbonrow {
    display:block;
    }
    //]]></style>
    </SharePoint:SPSecurityTrimmedControl>

    But this has not effect in my ribbon. The ribbon is not hidding. I am beginer in SharePoint 2013. Can you explain me step by step how to edit this master page and save it, to hide the ribbon?

    Thank you very much!

    ReplyDelete