truncate
This truncates a variable to a character length, default is 80. As
an optional second parameter, you can specify a string of text
to display at the end if the variable was truncated. The
characters in the string are included with the original truncation length.
By default, truncate will attempt to cut off at a word boundary. If
you want to cut off at the exact character length, pass the optional
third parameter of true.
Parameter Position
Type
Required
Default
Description
1
integer
No
80
This determines how many characters to truncate
to.
2
string
No
...
This is a text string that replaces the truncated text. Its length
is NOT included in the truncation length setting.
3
boolean
No
false
This determines whether or not to truncate at a
word boundary (false), or at the exact character (true).
4
boolean
No
false
This determines whether the truncation happens at the end of the
string (false), or in the middle of the string (true). Note that if this
setting is true, then word boundaries are ignored.
truncate
assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
?>
]]>
where template is:
This will output: