Ribbon button is a new feature in SP2010. It’s looks nice from a editors point of view and all WebParts seems controlled by the contextual ribbon panel.

But in customer sides, some times they don’t really need ribbon and want to hide Ribbon,Site Actions,Left Navigation,Bread Crumb,… in a single or more than one page.


Before

After

We can do it easy by many way.

1. The easy way to do so is using a content editor webpart and edit the content in html source mode and copy and paste the below CSS classes.

<style type=”text/css”>
#s4-ribbonrow { display:none } /*For Top ribbon*/
#s4-leftpanel { display:none } /*For Left navigation*/
.s4-ca { margin-left:0px;background:transaparent} /*to keep the margin starting from the left or else you will find a blank space if you use only the above class*/
.s4-breadcrumb-top { display : none } /*For Breadcrumb*/
#s4-titlerow { display:none } /*For Top bar*/
</style>

2. Use SPSecurityTrimmedControl you can define who should see the ribbon for page and webediting. We need to implement this control in your MasterPage, wrap any controls (in this case, the whole div that contains the ribbon) in:

<Sharepoint:SPSecurityTrimmedControl runat=”server” Permissions=”ManageWeb”>
//Your controls here
</SharePoint:SPSecurityTrimmedControl>

More info about this control and its parameters here:
http://fusionovation.com/blogs/mbell/archive/2008/09/18/security-trimmed-controls-in-sharepoint.aspx

3. Use code behind, other sites lack this functionality as does SharePoint Foundation. However, the code to do the hiding is simple:

public void HideRibbonForAnon()
{
SPRibbon current = SPRibbon.GetCurrent(this.Page);if (current != null && !this.Page.Request.IsAuthenticated)
{
current.CommandUIVisible = false;

SiteActions actions = SiteActions.GetCurrent(this.Page);

if (actions != null)
{
actions.Visible = false;
}
HideStatusBar();
}
}

internal void HideStatusBar()
{
string script =
“document.onreadystatechange=fnRemoveAllStatus; function fnRemoveAllStatus(){removeAllStatus(true)};”;
this.Page.ClientScript.RegisterClientScriptBlock(typeof(HideTheRibbon), “statusBarRemover”, script, true);
}

Hoang Nhut Nguyen
Email: nhutcmos@gmail.com
Skype: hoangnhut.nguyen
Related Article: