Monday, October 4, 2010

Document Icon in CQWP

You can find solution on some blogs like:-
http://edinkapic.blogspot.com/2007/09/document-icon-in-cqwp.html

But I got very short solution which is mentioned below:-

First, we should add the DocIcon in the CommonViewFields property (export the CQWP, edit the .webpart file) as follows:

<property name="CommonViewFields" type="string"">DocIcon, Lookup;</property">

Then, you can use following tempalte to get icon:-

<xsl:template name="RecentDcoument" match="Row[@Style='RecentDcoument']" mode="itemstyle">
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<div id="linkitem" class="item" style="vertical-align:middle;">
<div style="float:left;">
<IMG BORDER="0" ALT="{@FileLeafRef}" title="{@FileLeafRef}" SRC="/_layouts/images/{ddwrt:MapToIcon(string(@DocIcon),string(@DocIcon))}" />
</div>
<div>
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}" style="padding-left:5px;">
<xsl:value-of select="ddwrt:UrlBaseName(string($SafeLinkUrl))" />
</a>
</div>
</div>
</xsl:template>

No comments: