Question

SharePoint 2010.

I have created my own item style file with the name ItemStyleCustom.xsl. How can I use it for my Content Query WebPart?

Was it helpful?

Solution

Now add a fresh CQWP to your page and then export it. Save the generated file and open it in notepad. Locate property ItemXslLink and replace it with following: <property name="ItemXslLink" type="string">/Style Library/XSL Style Sheets/CustomItemStyle.xsl</property>

Locate property ItemStyle and replace it with following:<property name="ItemStyle" type="string">DetailedOverview</property>

Save the webpart file and upload it to the SharePoint page.

from http://sharepointnadeem.blogspot.se/2011/09/cqwp-xsl-customizations.html

Note that you will get only the item styles that are included in the CustomItemStyle.xsl; if you want the OOTB styles as well as your own, you need to include the templates from (or just start from a copy of) the OOTB ItemStyle.xsl.

OTHER TIPS

In order to provide custom ItemStyle.xsl for CQWP the ItemXslLink property should be specified.

There are several ways how to specify this property:

I presume you have already uploaded your custom ItemStyle.xsl file into \Style Library\XSL Style Sheets\

If you want to have just an additional Style to choose from for your CQWP you should not add another ItemStyle.xsl, but try to add another xsl-template to the existing itemstyle.xsl (make a backup before playing with the original one.

You just have to copy&paste an existing template like

<xsl:template name="TitleOnly" match="Row[@Style='TitleOnly']" mode="itemstyle">
…
</xsl:template>

And Change the name and @Style value to fit your new View.

Then Upload it to the \Style Library\ItemStyle.xsl Afterwards you can choose this new format in the settings of the cqwp.

You can also change the Layout of your headers with this way. A more detailed description can be found in an MSDN article

There is also the possibility to assign a itemstyle.xsl to just one cqwp with the help of the SharePoint Designer or Download and re-upload the cqwp but I wouldn’t recommend that.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top