Chapter 7. Customizing the SharePoint Experience with Delegate Controls
In this chapter, we will delve into the custom-delegate control model for adding custom code to SharePoint 2013. We will cover the following recipes:
Creating a Visual Studio solution for custom delegate controls
Adding JavaScript and stylesheets with an AdditionalPageHead delegate control
Customizing the suite bar branding with a SuiteBarBrandingDelegate delegate control
Customizing the suite bar links with a SuiteLinksDelegate delegate control
Adding Office 365-style drop-down menus to suite bar links
Adding promoted action links with the PromotedActions delegate control
Customizing header navigation with a TopNavigationDataSource delegate control
Customizing quick launch navigation with a QuickLaunchDataSource delegate control
Restoring the Navigate Up button with an AdditionalPageHead delegate control
Adding meta tags to pages from custom library fields with an AdditionalPageHead delegate control
Storing analytics tracking code with a site collection settings page
Adding stored analytics tracking code to pages with an AdditionalPageHead delegate control
Introduction
Microsoft SharePoint provides a variety of ways to add custom code to enhance or customize the SharePoint experience. These include web parts, timer jobs, application pages, delegate controls, custom actions, and so on. Delegate controls provide numerous locations on each SharePoint master page where default controls may be replaced with specified custom controls. This allows for SharePoint to place different controls on the page based on the features that are activated. For instance, when publishing features are enabled, SharePoint will use the delegate controls to add the publishing controls to the page.
In addition to the delegate controls provided (and required) on each SharePoint master page, additional delegate controls can be added to custom master pages. In this chapter, however, we will stick to the ones provided by SharePoint. The commonly used delegate controls provided by SharePoint are listed in the following table:
Control ID
Purpose
AdditionalPageHead
It adds controls to the <head> element of the page.
SuiteBarBrandingDelegate
It adds branding text to the top-left corner in the suite bar. Displays SharePoint by default.
SuiteLinksDelegate
It adds the suite links to the suite bar. Displays Newsfeed, SkyDrive, and Sites by default.
PromotedActions
It adds additional actions to the promoted actions on the top-right corner of the page. Using this delegate control does not remove the existing promoted actions.
TopNavigationDataSource
It adds the site map provider used by the horizontal navigation at the top of the page.
QuickLaunchDataSource
It adds the site map provider used by the vertical navigation on the left-hand side of the page.
TreeViewAndDataSource
It adds the tree view control and its site map provider when enabled.
GlobalNavigation
It adds a shared navigation control that renders above all other content on the page.