1. Open SharePoint Designer, Go to "Style Library/XSL Style Sheets/ItemStyle.xsl"
2. Add the below code
<div class="link-item">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<xsl:variable name="extension">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="@LinkUrl" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$extension = 'docx'">
<!-- add your logic -->
<img src="/images/icons/blogpost.png"></img>
</xsl:when>
<xsl:when test="$extension = 'xlsx'">
<!-- add your logic -->
<img src="/images/icons/Docment.png"></img>
</xsl:when>
</xsl:choose>
<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>
<div class="description">
<xsl:value-of select="@Description" />
</div>
</div>
_________________________
Add get file extension template
<xsl:template name="get-file-extension">
<xsl:param name="path"/>
<xsl:choose>
<xsl:when test="contains($path, '/')">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="substring-after($path, '/')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($path, '.')">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="substring-after($path, '.')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$path"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
2. Add the below code
<div class="link-item">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<xsl:variable name="extension">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="@LinkUrl" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$extension = 'docx'">
<!-- add your logic -->
<img src="/images/icons/blogpost.png"></img>
</xsl:when>
<xsl:when test="$extension = 'xlsx'">
<!-- add your logic -->
<img src="/images/icons/Docment.png"></img>
</xsl:when>
</xsl:choose>
<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>
<div class="description">
<xsl:value-of select="@Description" />
</div>
</div>
_________________________
Add get file extension template
<xsl:template name="get-file-extension">
<xsl:param name="path"/>
<xsl:choose>
<xsl:when test="contains($path, '/')">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="substring-after($path, '/')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($path, '.')">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="substring-after($path, '.')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$path"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
No comments:
Post a Comment