Archive

Archive for October, 2009

CQWP (Content Query Web Part) Display all fields + values

October 30, 2009 2 comments

Moved from old blogging site

Below is the code which I use frequently for my XSL development in CQWP. This xsl code gets all the data and values, this helps you identify all the data before you move on with visual html development. Initially I used this custom xslt to display all the field names in Content Query Web part. I modified it to see values along with field name. Its simple needs no explanation.


<xsl:template name="AllFields" match="Row[@Style='AllFields']" mode="itemstyle">
 <xsl:param name="CurPos"/>
 <xsl:variable name="SafeLinkUrl">
 <xsl:call-template name="OuterTemplate.GetSafeLink">
 <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
 </xsl:call-template>
 </xsl:variable>
 <xsl:variable name="SafeImageUrl">
 <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
 <xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
 </xsl:call-template>
 </xsl:variable>
 <xsl:variable name="DisplayTitle">
 <xsl:call-template name="OuterTemplate.GetTitle">
 <xsl:with-param name="Title" select="@Title"/>
 <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
 </xsl:call-template>
 </xsl:variable>
 <xsl:variable name="LinkTarget">
 <xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
 </xsl:variable>
 <div id="linkitem" class="item">
 <xsl:for-each select="@*">
 <span style ="font:bold">    <xsl:value-of select="name()" /> </span>  : <xsl:value-of select="."/> <br/>
 </xsl:for-each>
 </div>
 </xsl:template>

<p>&nbsp;</p>

——————————————

Categories: Content Query, Field, SharePoint, XSL, XSL Tags: ,