When working with customizing the Content Query Web Part (aka CQWP), you often want to know what you're dealing with. In this article I'm going to show you how you can show all the fields and their contents for all the items being displayed.
There are several suggestions out there on how to accomplish this, but here's my take. This recipe involves editing the style sheets (XSLT) for the CQWP. The CQWP uses three different style sheets for rendering the content set up to be displayed. By default these three are:
- /Style Library/XSL Style Sheets/ContentQueryMain.xsl
- /Style Library/XSL Style Sheets/Header.xsl
- /Style Library/XSL Style Sheets/ItemStyle.xsl
Using SharePoint Designer, open this file. Add the following template text in the bottom of the file (but before the closing tag):
<xsl:template name="ShowXML" match="Row[@Style='ShowXML']" mode="itemstyle">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
<xsl:value-of select="@Title" />
<xsl:value-of select="name()" />
<xsl:text disable-output-escaping="yes"> </xsl:text>
<xsl:value-of select="." />
- Save the file, and do a Check-in.
- Now go back to your page containing your CQWP, Edit Page, and choose Modify Shared Web Part on the CQWP.
- Under the Category Presentation, in the Item Styles dropdown list, now choose your new style called ShowXML. See screen shot below
- Finally, click Apply or OK.
For example of result, see screen shot below.
That's it! There's nothing to it!
But, the point of doing this in the first place is not only to see which fields you have available. You have probably created your own fields you want to use in the CQWP. So, to make them available here, I would like to send you over to Heather Solomons' excellent article on how to accomplish this. Check it out here: Customizing the Content Query Web Part and Custom Item Styles
For more information on how to customize the CQWP and its style sheets, check out my de.icio.us bookmarks on http://feeds.delicious.com/rss/frankove/cqwp. I won't bother posting all the links in this post, since I constantly find new good links. But here are a few good ones:
- Customizing the Content Query Web Part and Custom Item Styles
- Microsoft Enterprise Content Management (ECM) Team Blog : Configuring and Customizing the Content Query Web Part
- How to: Customize XSL for the Content Query Web Part
- Paul Galvin's SharePoint space: Display Content Query Web Part Results in a Grid / Table