Today I discovered an issue with some customisations I did for a client. The customisations involved changing the ItemStyle.xsl file, to add new templates for a Content Query Web Part.
More specifically, the client wanted to show a view of news items, the latest news item to be displayed in full, and the remaining x number of items to display in summary form.
This can be done with a test for preceding sibling nodes, e.g.
This particular client had one more specific requirement, to also show images associated to the latest News Item. To do this, I created a new XSL variable, pulling in the URL of the image with the following code:
<xsl:variable name="NewsItemImage"> <xsl:call-template name="OuterTemplate.FormatValueIntoUrl"> <xsl:with-param name="Value" select="@ImageUrl"> </xsl:with-param> </xsl:call-template> </xsl:variable>
After some fiddling around with HTML to ensure news items would display in a pleasant manner, I checked in all changes to ItemStyle.xsl, and finished configuring the Content Query Web Part's Item style (under Modify Shared Web Part -> Presentation) to use the new style. All was good in the world.
But, a few days later after the client had begun adding content to the site, they noticed they couldn't add Summary Link Web Parts. All Summary Link Web Parts would display the old "Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint" error message.
After digging around in the SharePoint log files, I found that every time a page that contains a Summary Link Web Part was loaded, the following error would occur:
The named template 'OuterTemplate.FormatValueIntoUrl' does not exist. An error occurred at http://xxx/Style Library/XSL Style Sheets/ItemStyle.xsl(392,10). at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver) at Microsoft.SharePoint.WebPartPages.DataFormWebPart.GetXslCompiledTransform()
So apparently, the OuterTemplate in the of a Summary Link Web Part doesn't have the same <xsl:template>'s defined as the OuterTemplate of a Web Part that sources data from a list. This makes sense, since the links contained in a Summary Link Web Part are stored within the Web Part contents themselves, and not queried from elsewhere in the site.
Add a dummy <xsl:template name="OuterTemplate.FormatValueIntoUrl"> element to the bottom of your ItemStyle.xsl. That way, when the Summary Link Web Part tries to validate the contents of ItemStyle.xsl, it has an <xsl:template> to refer to for "OuterTemplate.FormatValueIntoUrl", and when the Content Query Web Part parses the data through the Item Style, it refers to it's real OuterTemplate's <xsl:template> instead. Here's an example of the actual XSL code to add:
<!-- The following is used to fool the summary links web part into thinking the OuterTemplate.FormatValueIntoUrl template exists --> <xsl:template name="OuterTemplate.FormatValueIntoUrl"></xsl:template>