截取
从字符串开始处截取某长度的字符.默认是80个.
你也可以指定第二个参数作为追加在截取字符串后面的文本字串.该追加字串被计算在截取长度中。
默认情况下,smarty会截取到一个词的末尾。
如果你想要精确的截取多少个字符,把第三个参数改为"true"

Parameter Position参数位置Type参数类型Required必需Default默认Description描述
1integerNo80 截取字符的数量
2stringNo... 截取后追加在截取词后面的字符串
3booleanNofalse 是截取到词的边界(假)还是精确到字符(真)

例子:
articleTitle:Two Sisters Reunite after Eighteen Years at Checkout Counter.

模板:

_{$articleTitle}_
_{$articleTitle|truncate}_
_{$articleTitle|truncate:30}_
_{$articleTitle|truncate:30:""}_
_{$articleTitle|truncate:30:"---"}_
_{$articleTitle|truncate:30:"":true}_
_{$articleTitle|truncate:30:"...":true}_

输出:

Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after...
Two Sisters Reunite after
Two Sisters Reunite after---
Two Sisters Reunite after Eigh
Two Sisters Reunite after E...