This post was published to My Blog at 13:49:12 05/08/2011
[Enter Post Title Here]
One of the first tasks I had in setting up the public-facing SP2010 site was the ability to
hide the ribbon to anonymous users. As a Systems Engineer mainly concerned with
infrastructure my programing level can be described as basic. I am interested in
content management and deploying SharePoint solutions and capabilities with minimum
modification to code as possible.
I investigated several approaches to resolve this problem and opted to try the use of
the security trimmed control which can be used to not load the ribbon if not
authenticated. This seemed to work fine, but, I soon realized that there was a problem
with the vertical scroll bar being hidden. It seems that the reason for this is that
SharePoint hides the scroll bar and adds a custom scroll bar to assist the ribbon to stick
to the top. When the ribbon is hidden the scroll bar is also hidden as SharePoint uses
overflow, hidden in Cascading Style Sheets CSS for the body, so it can handle the scroll
bar.
This led to take both of them to construct the best solution. I used the security trimmed
control to hide the ribbon, and then I used the control from the forum post and
modified the CSS to handle the scrollbar. Here are the steps combining both of the
solutions and including my addition.
Here is the solution which hides the ribbon from Anonymous users, and enables the
scroll bar too. I assume you know how to use SharePoint Designer, and that you know
how to modify the default.master page.
1. Add the following before the start of the ribbon.
The ribbon starts here.
2. Then close the security trimmed control at the end of the ribbon. It should look like
the following.
3. For the scroll bar problem, add the following outside of the security trimmed control
(I put it before, but it doesn’t matter). You’ll notice now the body is set to scroll on
overflow, and since it’s on the page it will trump the SharePoint style due to the
cascade.
body { overflow-y: scroll !important; overflow-x: hidden; }
body #s4-workspace { overflow-x: hidden; overflow-y: auto !important; }
html { overflow: auto !important; overflow-x: hidden; }
body { overflow: auto !important; }
That’s it! It should be noted that there is no logon button in this solution; this for me is
not yet a problem. If the need arises I will place an update on how to add this function.
Well, Well.. It seems that the more I work with SharePoint, the better I become and
solutions become simpler as I progress. It really was a struggle when I started out,
loosing large amounts of time on the simplest of tasks. If you are reading this, I am
sure that you will agree.
In fact, since the writing of this article I have found an easier, flexible and more elegant
way to hide the ribbon by using a web solution which can be downloaded from CodePlex.
http://spribbonvisibility.codeplex.com/
It’s true that once you apply this method of hiding the ribbon, let’s say for anonymous
users. You will not have a means to logon to your site as it also hides the “Sign in” link.
This is very easily solved, even if it took me a good hour to figure it out.
My solution was to add the following code to footer on the master page of my site using
SPD.
This will give you something like this…
And this when not logged on.
And don’t forget to use SSL if you intend to authenticate over the internet, otherwise
your passwords can easily be intercepted.
See my other posting on setting up SSL for a WFE.