Documentation: TruncHTML

Installation:

Unzip the archive and copy the folder trunchtml into the /expressionengine/third_party/-directory inside your system-directory.

Usage example:

Wrap any text/html you want to be truncated inside an {exp:trunchtml}-tag-pair.

{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.

threshold="X" 

If this is set the text will only be truncated if it at least X characters long.
Otherwise the full text is returned.

 

Changelog:

  • Version 2.0
    • Initial release for ExpressionEngine 2