Add custom styles to SummaryLinkWebPart

Add custom styles to the SummaryLinkWebPart. This technique can also be applied to the TableOfContents WebPart and the Content Query WebPart

The SummaryLinkWebPart has many styles in it, but if you need to brand it to your company’s then you can add custom styles.

Introduction to SummaryLinkWebPart

Add the webpart. It is in the category Content Rollup. See on MSDN what you can do with this webpart.

Add SummaryLinkWebPart

Clean SummaryLinkWebParts

Configure styles and layout to set the layout of your style. Default styles in SummaryLinkWebPart

Configuring SummaryLinkWebPart

Next you do an export of the webpart. In the file you can add custom links to stylesheets.

<property name="HeaderXslLink" type="string" />
<property name="MainXslLink" type="string" />
<property name="ItemXslLink" type="string" />

Customizing XSL stylesheets

This stylesheets are located in the stylelibrary. Take a copy of them to see how SharePoint created this files.

SharePoint Style Library

The custom stylesheet can be very simple.


  exclude-result-prefixes="x d ddwrt xsl msxsl"
  <xsl:template name="CustomHeader" match="*" mode="header">
      <xsl:call-template name="OuterTemplate.GetGroupName">
        <xsl:with-param name="GroupName" select="@*[name()=$Group]"/>
        <xsl:with-param name="GroupType" select="$GroupType"/>


  exclude-result-prefixes="x d xsl msxsl cmswrt"
  xmlns:xsl="" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
  <xsl:param name="ItemsHaveStreams">
    <xsl:value-of select="'False'" />
  <xsl:variable name="OnClickTargetAttribute"
    select="string(';_blank&quot;')" />
  <xsl:variable name="ImageWidth" />
  <xsl:variable name="ImageHeight" />
  <xsl:template name="MyItemStyle" match="Row[@Style='MyItemStyle']" mode="itemstyle">
    <xsl:variable name="SafeLinkUrl">
    <xsl:call-template name="OuterTemplate.GetSafeLink">
      <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
  <xsl:variable name="DisplayTitle">
    <xsl:call-template name="OuterTemplate.GetTitle">
      <xsl:with-param name="Title" select="@Title"/>
      <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
  <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
    <a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
      <xsl:if test="$ItemsHaveStreams = 'True'">
        <xsl:attribute name="onclick">
          <xsl:value-of select="@OnClickForWebRendering"/>
      <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
        <xsl:attribute name="onclick">
          <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
      <xsl:value-of select="$DisplayTitle"/>

Create webpart file

Next we upload the custom styles and make a reference to the custom stylesheet in the webpart file.

<property name="HeaderXslLink" type="string">/Style%20Library/XSL%20Style%20Sheets/MyHeader.xsl</property>
<property name="MainXslLink" type="string">/Style%20Library/XSL%20Style%20Sheets/MySummaryLinkMain.xsl</property>
<property name="ItemXslLink" type="string" >/Style%20Library/XSL%20Style%20Sheets/MyItemStyle.xsl</property>

Choosing the styles in the SummaryLinkWebPart now looks like this. Only the style configured in the custom stylesheets are shown in the option list.

Select custom style


This way of styling can also be applied to TableOfContents WebPart and Content Query WebPart. First time you do this it can look complicated but it is not.

To Blog