Thursday, March 8, 2007

Displaying a Document Icon in a Data View

To display the correct document icon in a dataview, use the following XSLT source:

<a target="_self">
<xsl:attribute name="href">
<xsl:value-of select="@FileRef"/>
<img border="0">
<xsl:attribute name="src">
<xsl:value-of select="ddwrt:MapToIcon(string(@HTML_x0020_File_x0020_Type),string(@File_x0020_Type))"/>

The MapToIcon method derives the correct icon name from the supplier document type (but note it returns only the icon file name, not the path).

No comments: