Having trouble with HTML truncate utilities
This is an open discussion with 3 replies, filed under Troubleshooting.
Search
@nathanhornby - What happens when you call it this way...
<xsl:apply-templates select="content/*" mode="truncate" limit="50"/>
I use this code to limit the length of a text. Maybe it is another starting point.
<xsl:template name="get-intro">
<xsl:param name="limit"/>
<xsl:value-of select="substring(body, 1, $limit + string-length(substring-before(substring(body, $limit + 1),' ')))" disable-output-escaping="yes" />
<xsl:if test="string-length(body) > $limit + 1" >
<xsl:text> ...</xsl:text>
</xsl:if>
</xsl:template>
@bzerangue Actually I think I may have already been using content/*
- I certainly tried it!
Very neat little utility @plenaforma - may give that one a go next time I need it!
Create an account or sign in to comment.
Not sure what I'm doing wrong here, but whatever I try I can't get either of the HTML truncation utilities to work. I managed to get this one from SO to work right off the bat, but unfortunately it seems to truncate each element within the node, as the content is formatted this means I get several truncated lines back, not what anyone needs. Edit: I managed to almost get this script working (from Allen, I later noticed!) however I'm getting 3 ellipses' after the truncation so it's clearly not working entirely as intended. The utilities hosted here look more robust, assuming I can get one to work.
My node looks like:
And I'm calling it using:
With HTML Truncate Advanced I'm just getting an unformatted version of the content back. Nothing is truncated. HTML Truncate returns nothing at all.
Neither utility really explains how to use it so not sure where else to turn.
Any advice?
EDIT: I gave up in the end and am using a user-defined excerpt (not always convenient, but in this case it's fine). Would be great to hear what I was doing wrong though, for the future.