SharePoint 2013 features a new set of links called the Suite Bar Links that are displayed in the top right corner of every SharePoint page. By default these links include “Newsfeed”, “SkyDrive”, and “Sites”.

When first seeing this links my first thought was “how do I change them?”. In exploring the master page, we can see that the links are added to the page with this delegate control:

This presents two options for changing the links:

1. Remove the delegate control (or hide it) and simply hard code the links in the master page. This is only a viable option if you using a single language site and you are only making the changes for a single site collection. If you were using a multilingual site, you would lose the automatically translated links that SharePoint provides. And you would need to make this change in the master pages of every site collection.

2. Override the delegate control with a custom control. This presents a unique challenge in that all of the default links are hard-coded in non-public methods of the SharePoint assemblies.

Creating a Custom Delegate Control to Override SuiteLinksDelegate

The goal with this custom control is to maintain the same functionality as the built-in SuiteLinksDelegate control while adding our own links. To do this, we are going to use similar code to what the built-in control uses, some .NET reflection, and some techniques of my own.

To get started, ensure that you have SharePoint 2013 installed and configured along with Visual Studio 2012 installed with the SharePoint 2013 developer tools.

  1. Launch Visual Studio 2012 and create a new project: Templates > Visual C# > Office/SharePoint > SharePoint Solutions > SharePoint 2013 Project. For this example, I named the project “SharePointDelegates”. When prompted, select Farm Solution as the solution type.

  2. Add the following references to your project (you will need to browse to C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions15ISAPI): Microsoft.Office.Server.dll, Microsoft.Office.Server.Search.dll, Microsoft.Office.Server.UserProfiles.dll, and Microsoft.SharePoint.Portal.dll.

  3. Add a “UrlUtility” class (right-click the solution name > Add > Class.

  4. The UrlUtility class is used by the default SuiteLinksDelegate control and rather than reinvent the wheel, we are just copying the class from the SharePoint assemblies:

  5. Add a “SuiteLinksHelper” class.

  6. The SuiteLinksHelper class contains methods that mimic the internal SharePoint methods used by the SuiteLinksDelegate control. In places that accessed other internal SharePoint methods, .NET reflection is used instead to access the same methods.

  7. Add a new Empty Element to create the Delegate Control override reference. (Right-click solution name > Add > New Item > Empty Element (in the Office/SharePoint group). For this example, I used “SuiteLinksControl” as the name of the element.

  8. In the Elements.xml file of the Empty Element, we are using some XML to specify the Id of the Delegate Control to override and the source of our custom user control (which we haven’t created yet):

  9. In the Solution Explorer, highligh the Empty Element (SuiteLinksControl). In the Properties window, select the […] button for the Safe Controls property to open the Safe Control Entries window.

  10. Add a new Safe Control entry for our custom user control (which we haven’t created yet):

    • Name: SharePointDelegatesControlTemplates
    • Assembly: $SharePoint.Project.AssemblyFullName$
    • Namespace: SharePointDelegates.CONTROLTEMPLATES.SharePointDelegates
    • Safe: True
    • Safe Against Script: True
    • Type Name: *
  11. When we add the Empty Element, a new Feature was automatically added. In the Solution Explorer rename it to something more meaningful (like SuiteLinksFeature).

  12. Open the SuiteLinksFeature and set the scope to Farm. In addition, you should change the Title to something more meaningful (like “Custom Suite Links”). The Title is what gets displayed on the Features page when activating it.

  13. Add the CONTROLTEMPLATES SharePoint mapped folder (right-click Solution Name > Add > Add SharePoint Mapped Folder > Expand TEMPLATE and Select CONTROLTEMPLATES.

  14. To ensure no conflicts occur, add a new folder under the CONTROLTEMPLATES folder with the same name as the solution (like “SharePointDelegates”).

  15. Add a new user control to the SharePointDelegates folder called “SuiteLinksControl.ascx”. (Right-click the SharePointDelegates folder > Add > New Item > User Control (Farm Solution only)

  16. Open the SuiteLinksControl.ascx.cs file and add the following code:

  17. Now that we have our custom control ready to go we can deploy the solution and test. (Right-click the solution name > Deploy)

  18. You should now see the new links at the top right corner of the page when you open your SharePoint site.

That’s it. There is a lot of opportunity to extend this idea (such as with an administration page to manage custom links). It is just unfortunate that Microsoft hard-coded these links rather than making them configurable.

Pin It on Pinterest

Share This
%d bloggers like this: