Plugins
Most current version is 1.2.2
- Truncates HTML/Text after the specified number of characters.
- Does not count characters in HTML-tags.
- Does not cut-off in the middle of tags.
- Closes all open tags.
So if you limit the following text to 80 chars…
<p class="quote"><b>Never let your sense of morals get in the way of doing what's right.<br />
<em>Isaac Asimov</em></b></p>
the result will be ...
<p class="quote"><b>Never let your sense of morals get in the way of doing what's right.<br />
<em>Isaac</em></b></p>
instead of ...
<p class="quote"><b>Never let your sense of morals get in the way of doing what's
... which would probably screw the rest of the page.
Example:
{exp:trunchtml chars="300" ending="<a href='{path=site/comments}'>read on</a>"}
{body}
{/exp:trunchtml}
Parameters:
chars="100"
Defaults to 500. Number of characters that are to be returned.
ending="..."
Optional. String to be added after the output.
inline="..."
Optional. This string is placed directly after the truncated text and before any closing tags. If you want the first character to be a space, use an underscore
e.g. inline="_continue”
exact="yes"
If this is set, text will be truncated after exactly the specified number of chars. Otherwise text will be cut after a space to prevent cutting words in the middle.

Download: pi.trunchtml.zip
2.54 KB
If you found something useful here and want to show your appreciation feel free to
or
Comments:
1 of 4 pages 1 2 3 > Letzte »
@ Edward:
In version 1.2.2 the leading space before the inline-text is removed.
If you want a leading space on first position in the inline-text use an underscore instead, e. g. inline="_foo".
Posted by on 02/15 at 08:52 PM
Thank you! Works much better for me than the other limiters. Some question-marks about the performance of inline and ending but for now it is not important, my page look good and validates in strict mode. Cheers!
Posted by on 02/07 at 12:59 PM
I’m using 1.2.1 and it works really well except for one thing: I have an ellipsis (...) being displayed using that new “inline” parameter but it always adds a space before it. Thus, sometimes the line will break right _before_ the ellipsis and it’ll end up on a line by itself. Hope a future version will fix.
Many thanks!
Posted by on 01/23 at 06:16 PM
I am impressed with the plugin but find that I cannot use it as a replacement for Word Limiter Plus because there is a line-break placed before the ending bit, whereas I need it to appear on the same line as the preceding text. I tried using “inline” for my “read on...” link but then it is affected by the formatting of the preceding text. Given that a line-break can be scripted into the ending bit I think the default should be no line-break, or there should be a parameter available for this.
Please let me know if and once this functionality is made available!
Also useful would be if_exceeds functionality a la Word Limiter Plus.
Posted by David on 11/28 at 01:34 AM
I had a lot of spaces after the text i wanted truncated which was a reason why it was adding “...” even though it was well under 60 characters.
Still having the issue wtih some text though
{exp:trunchtml chars="60" inline="..."}{title} lots of spaces here {/exp:trunchtml}
This is 35 characters long or so, but still having “...” added. Again, very random,
“Transformers Custom Protoform Starscream ...”
Posted by on 10/07 at 04:00 PM
1 of 4 pages 1 2 3 > Letzte »