How to apply "HTML Truncate Advanced" utility without the text editor styles
This is an open discussion with 4 replies, filed under XSLT.
Search
using the "HTML Truncate Advanced" utility
This utility is for when you specifically want to retain styling (HTML tags) in content. If you don't, try a much simpler truncate template such as:
<xsl:template name="truncate"> <xsl:param name="text"/> <xsl:param name="length" select="'140'"/> <xsl:choose> <xsl:when test="string-length($text) > $length"> <xsl:value-of select="concat(normalize-space(substring($text, 1, $length)),'…')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template>
Use it like:
<xsl:call-template name="truncate"> <xsl:with-param name="text" select="path/to/content/node"/> <xsl:with-param name="length" select="'300'"/> </xsl:call-template>
hi,
my problem is need to display the whole last word. so i used the "HTML Truncate Advanced" utility with the help of my previous discussion (How to display the First N Words in symphony). but now also i am not getting the wold last word by using the new "truncate template" , could you please tell how to solve this..
thanks
Ah, you should've said ;-)
Hi,
Thank u so much..
finally I got the output which i required exactly with the help of "truncate-string-by-words.xsl" which u mentioned above ..
thanks a lot. :)
Create an account or sign in to comment.
hi,
Could anyone Please tell how to get only the text without applying styles at the time of using the "HTML Truncate Advanced" utility. I am using content editor for adding the content, but i need only the text without applying the styles which added using the editor.
Now i am getting the text with styles like bold, italic, horizontal line, etc.,
thanks