Sharepoint CQWP: XSL template to display document details
By peter.stilgoe
An example XSL template to display document details in a content query webpart:
<xsl:template name="DocumentsDetails" match="Row[@Style='DocumentsDetails']" mode="itemstyle">
<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="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="''"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
<xsl:with-param name="UseFileName" select="1"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayAuthor">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="''"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
<xsl:with-param name="UseFileName" select="1"/>
</xsl:call-template>
</xsl:variable>
<div class="item link-item">
<xsl:if test="string-length(@DocumentIconImageUrl) != 0">
<div class="image-area-left">
<a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
<xsl:if test="$ItemsHaveStreams = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of select="@OnClickForWebRendering"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
</xsl:attribute>
</xsl:if>
<img class="image" src="{@DocumentIconImageUrl}" title="" />
</a>
</div>
</xsl:if>
<div class="link-item">
<div style="color: black; font-family: Arial, Helvetica, sans-serif; line-height: -2%">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
<xsl:if test="$ItemsHaveStreams = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of select="@OnClickForWebRendering"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
<xsl:attribute name="onclick">
<xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
</xsl:attribute>
</xsl:if>
<xsl:value-of select="$DisplayTitle"/>
</a> | <xsl:value-of select="@Author" /> | <xsl:value-of disable-output-escaping="no" select="ddwrt:FormatDate(string(@Description), 2057, 5)" />
</div>
</div>
</div>
</xsl:template>
A returned file in the CQWP will display:
Plan 36 | xxxxxx\StilgoeP | 01/06/2011 09:35
Doc Icon (links to doc) – Doc Title (links to doc) – Author – Modified Date & Time
More From pstilgoe
How to add extra fields to your CQWP that dont display as standard
By peter.stilgoe
1) Export your Content Query Web part to your desktop
2) Open it with Notepad and look for the following line of code:
3) Change this line to the following, and replace the portion MYINTERNALCOUMNNAME with the internal column name for your column
4) Save your file
5) Import the web part
- Edit page
- Add Web Parts
- Switch to advanced
- Switch from browse to import
- Browse to your file and upload you file
Now when you go to apply a filter, you will see your custom column.



June 1st, 2011
