Print Shortlink

Adding your own links to SharePoint 2013 suite bar

OK, so if you had a chance to work with SharePoint 2013, you know that it has this great concept of a suite bar; basically a strip that shows on the top of the ribbon on each page and site, and shows links to things like: NewsFeed, Skydrive, Sites.
Suite bar is divided in two parts, the one showing NewsFeed, Skydrive etc; and the part which shows a welcome link, Settings icon etc.
There is no easy was to add links to none of them.
In this post, I’ll demonstrate a very clean approach on how you can add new links to Newsfeed, Skydrive etc strip Here it goes: 1. Since the suite bar is designed as an out-of-the-box delegate control, we’ll create our own inheriting from it. Create a new Visual Studio 2012 solution and add a new feature to it, let’s call it ProvisionSuiteBar and make it a Farm feature
2. Add an Empty Element project item named SuiteLinksDelegate and add the following code into the Elements.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control Id="SuiteLinksDelegate" Sequence="90"
ControlSrc="~/_ControlTemplates/15/SharePointProject1/CustomSuiteBar.ascx" />
</Elements>

3. Add a new User Control project item with the name CustomSuiteBar.ascx and switch to its code behind
4. Add the following method right after the Page_Load in CustomSuiteBar.ascx.cs:

protected override void Render(HtmlTextWriter writer)
{
writer.Style);
writer.Write(".ms-core-suiteLinkList {display: inline-block;}");
writer.RenderEndTag();
writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-core-suiteLinkList");
writer.Ul);
RenderSuiteLink(writer, "/", "Home", "HomeLink", false);
writer.RenderEndTag();
base.Render(writer);
}

5. Add a reference to Microsoft.SharePoint.Portal
6. Ensure your control inherits from MySuiteLinksUserControl like this:

public partial class CustomSuiteBar : MySuiteLinksUserControl

7. Deploy the solution and here it is, the home link has now been added to the rest of the suite bar:

Of course you can write any custom logic as to what icons are going to appear there .. security trimmed and so on :)

Lot’s of cool stuff like this is coming in my upcoming SharePoint 2013 book, so stay tuned.

Enjoy!