Encouraging two-way communications

Share + Learn + Comment   Encouraging two-way communications

Discover our team’s valuable knowledge, experience, opinions, and advice. And let us know what you think!

Blog

Creating Site-level Ribbon Tabs in SharePoint 2010 and Hiding Ribbon on Demand

In this article I will assume you have already read and understand how to provision ribbon on the page. If not, refer to this article.

Here we’ll focus on what you need to do to create a new ribbon tab on the site level, which seems to be a hot topic these days. You need to perform two things:

1. In your SharePoint 2010 project, add a new empty element item and define the following XML:

 <[default] ”http://schemas.microsoft.com/sharepoint/”:Elements xmlns="”http://schemas.microsoft.com/sharepoint/”"> <[default] ”http://schemas.microsoft.com/sharepoint/”:CustomAction id="”MyProject.RibbonButton”" Location="”CommandUI.Ribbon”"> <[default] ”http://schemas.microsoft.com/sharepoint/”:CommandUIExtension> <[default] ”http://schemas.microsoft.com/sharepoint/”:CommandUIDefinitions> <[default] ”http://schemas.microsoft.com/sharepoint/”:CommandUIDefinition Location="”Ribbon.Tabs._children”"> <[default] ”http://schemas.microsoft.com/sharepoint/”:Tab id="”MyProject.Ribbon.HelloTab”" title="”Custom"> <[default] ”http://schemas.microsoft.com/sharepoint/”:Scaling id="”Ribbon.Read.Scaling”">  <[default] ”http://schemas.microsoft.com/sharepoint/”:Groups id="”Ribbon.Read.Groups”">        

Feel free to add any controls to your group as needed.

2. Enable this tab on each page of your site. This step is something very specific to site-wide ribbon tabs. To achieve the goal you can either create a user control that will sit in your masterpage (header or footer) or delegate control and it will be called on each page. The code that you will run in this user control will be something like this:

Microsoft.SharePoint.WebControls.SPRibbon.GetCurrent(this.Page).MakeTabAvailable(”MyProject.Ribbon.HelloTab”);

You can use this to verify that the tab was already enabled:

Microsoft.SharePoint.WebControls.SPRibbon.GetCurrent(this.Page).MakeTabAvailable(”MyProject.Ribbon.HelloTab”);

Keep in mind that this needs to run each time the page is loaded and the tab will show up along with all of the rest of the contextual tabs.

In some cases you would want to disable the whole ribbon in your page. How do you do that?

You need to follow Step 2 and create user control or a delegate control, but this time it will call the following code:

Microsoft.SharePoint.WebControls.SPRibbon.GetCurrent(this.Page).CommandUIVisible = false;

Good luck!

  • Facebook
  • Twitter
  • DZone It!
  • Digg It!
  • StumbleUpon
  • Technorati
  • Del.icio.us
  • NewsVine
  • Reddit
  • Blinklist
  • Add diigo bookmark
Post a comment
  1. Formatting options
       
     
     
     
     
       

Please Upgrade Your Browser

This site's design is only visible in a graphical browser that supports web standards, but its content is accessible to any browser or Internet device.