But you can make an XSL file for each content query webpart and here is how to do:
- Edit the page you want to add the webpart in.
- Add a content query webpart.
- Export the webpart.
- Open the exported file.
- Search for “ItemXslLink”
- Update the line to:
<property name="ItemXslLink" type="string">/Styles/XSL/MyCQWebpart.xsl</property> - Update the property "ItemStyle" to the templete name ("UsefulLinks" in this example)
- Upload the XSL file (remember to update "CommonViewFields" as needed)
- The XSL file can be something like this to display a useful links (Title, Link):
<xsl:stylesheet version="1.0" exclude-result-prefixes="x d xsl msxsl cmswrt" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:template name="UsefulLinks" match="Row[@Style='UsefulLinks']" mode="itemstyle">
<xsl:param name="CurPos" />
<xsl:variable name="TitleLenght" select="string-length(@Title)" />
<xsl:variable name="RowLimit" select="40" />
<xsl:variable name="LinkURL" select="substring-before(@Link,',')" />
<xsl:variable name="LinkText" select="substring-after(@Link,',')" />
<li>
<a href="{$LinkURL}" target="_blank" title="{$LinkText}" class="newsTitle">
<xsl:value-of select="$CurPos" /> - <xsl:value-of select="@Title" />
</a>
</li>
</xsl:template>
</xsl:stylesheet> - Import the webpart and configure it to read from the right place, filtration and sorting order and so on.
- Go to the “ContentQueryMain.xsl” file and search for “OuterTemplate.CallItemTemplate”
- In <xsl:apply-templates select="." mode="itemstyle"> add <xsl:with-param name="CurPos" select="$CurPosition" /> and any other parameters you want to send to the itemstyle.
- You can also make your own ContentQueryMain XSL by updating the “MainXslLink” property in the webpart file, and the same for the header by updating the “HeaderXslLink” property.