Thursday, October 11, 2007

CQWP debug item style

Reading this post a few months ago I found this great tip. If you want to know what are the fields that your CQWP receives you can use this item style to "debug" it.

<xsl:template name="Debug" match="Row[@Style='Debug']" mode="itemstyle">
<xsl:for-each select="@*">
            <br>
                <xsl:value-of select="name()" />
            </br>
        </xsl:for-each>
</xsl:template>

It will show all the fields passed to the web part (internal names). I recommend you to read the entire article; it shows the basis about the customization of the CQWP.

Related links:
http://blogs.msdn.com/ecm/archive/2006/10/25/configuring-and-customizing-the-content-query-web-part.aspx

3 comments:

Anonymous said...

Hi,

is there a possibility also to show the content of the returned fields?

greetz, Kristof

Àlex said...

In order to get the value of a passed field to a CQWP you can use the following XSLT templete:

<xsl:template name="test" match="Row[@Style='test']" mode="itemstyle">
<xsl:value-of select="@fieldname" disable-output-escaping="yes"/>
</xsl:template>

The attribute disable-output-escaping allows to show the "HTML value". By default it is set to "No".

I tried to make a template to get a list with all fields and the associated values but it did not work because I was unable to get the value for each item.

Unknown said...

if you want to view the value of the current row simply select="."

eg <xsl:value-of select="." disable-output-escaping="yes"/>

Thanks,
R. Kozar

 
Online Visitors