Written by: Dustin Schieler 6/19/2012 12:49 PM
Out of the box, SharePoint's Publishing Site Masterpage will render all the Ribbon code in your page to the outside world, even though the visiting user is anonymous. All they need to see is the published content of web site, not all the backend stuff the site editors need to have access to. Now without the proper credentials, your site is still safe this way; none of the editing controls (even thought they are in the page source) are available to them. However, because of all the unused code being pulled down by the browser with every page load, this means your server will suffer some performance issues unnecessarily.
Go into the Masterpage with SharePoint Designer and make these changes. Follow the comment directions carefully:
<Sharepoint:SPSecurityTrimmedControl runat="server"
Permissions="OpenItems">
<!-- Here is where the code for the Ribbon
goes. It should start with <div class="ribbonbackground" then it ends several
lines down with something like
</asp:UpdatePanel></div></div></div> Add the next lines
just below -->
<style type="text/css">
/* Uses CSS here to hide
or change the position of elements you don't want visible if not logged in
*/
#s4-workspace
{
padding-top: 0px !important;
/* You have to use
!important to make your alternate styles work */
}
</style>
</Sharepoint:SPSecurityTrimmedControl>
<!-- Now style elements the way
you want them visible or positioned when not signed in, the next line is already
a little ways further down in your masterpage, just add in the alternate
style-->
<div id="s4-workspace" style="top: -1px; padding-top:
25px;">
<!-- Add this next div to produce a link that says "Sign In"
at the top. It's absolute positioned, but you can always adjust your CSS as
required -->
<div id="SignInLink" style="color: white; z-index:10000;
position:relative; float: right; margin-right: 20px; margin-top: -20px;
font-size: 12px;" runat="server">
<a style="color: white;"
href="/_layouts/Authenticate.aspx">Sign In</a>
</div>
That's really all you have to do, and it can all be done inside of SharePoint Designer. The control that does the magic is:
<!-- Content you only want seen/rendered when
signed in goes here -->
The best part is that it keeps the server from rendering code when it doesn't need to and in turn, helps cut down on server load. I think it's a very bad idea to try to hide the Ribbon with jQuery or JavaScript for this reason. You can use this trick over and over inside your Masterpage to hide all sorts of elements you don't want your anonymous users to see (or have rendered on their side). Furthermore, if you change the Permissions="OpenItems" to other parameters, (see http://www.topsharepoint.com/hide-the-ribbon-from-anonymous-users ) you can hide different things at different permission levels.
A quick note on others' methods of this trick: I have found that "OpenItems" works better than "ManageLists" because your users will probably still want to see the Ribbon when they are logged in, even if they don't have permission to do anything to the page or site they are on. Users seem to get confused when they Sign In, but can't see the Ribbon, even though they are not allowed to do anything on that specific page.
0 comment(s) so far...
Designed by Dustin Schieler Google+