1

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?

3 Answers 3

2

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.

2
  • It works, but now I see only my custom itemstyles in the dropdown. Is this normal? I was expecting also the original itemstyles.
    – Ola
    Commented Sep 12, 2013 at 15:12
  • This is normal, you can only have one Commented Sep 12, 2013 at 16:12
2

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\

1

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.

3
  • It is actually quite interesting that Microsoft tells you to modify the OOTB files, normally this is a big no no ;) Commented Sep 12, 2013 at 13:57
  • Yep, I agree with that. But my last tries to add an default ItemStyle to just one cqwp instead of providing a new style for all cqwp in the collection showed me that microsoft really wants to keep everything in one xsl file instead of creating your own "area" of changes ;)
    – Leviani
    Commented Sep 12, 2013 at 14:01
  • True, though you can make it just affect on by using the method I show below :) Commented Sep 12, 2013 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.