When created news, articles, and etc..., I want to take part of article as summary displayed in listing and headlines.I Created XSLT which can be used for this functionality:
You can call this template by the following:
<xsl:template name="trimPara"> <!-- pass the string to be cropped with required string length --> <xsl:param name="stringLenRequired"/> <xsl:param name="stringInput"/> <xsl:value-of disable-output-escaping="yes" select="substring($stringInput,1,number($stringLenRequired))"/> <xsl:value-of disable-output-escaping="yes" select="substring-before(concat(substring($stringInput,number($stringLenRequired)+1,number($stringLenRequired) +20),' ' ),' ')"/> <!-- to make it a full word --> <xsl:if test="string-length($stringInput) > number($stringLenRequired)">...</xsl:if> </xsl:template> |
You can call this template by the following:
<xsl:call-template name="trimPara"> <xsl:with-param name="stringLenRequired">200</xsl:with-param> <xsl:with-param name="stringInput" select="@Body"/> </xsl:call-template> </div> |
No comments:
Post a Comment