我收到smarty中的段落内容。在显示时我只需要显示25个字符,如何限制smarty中的字符。
<p>{$myresult}</p>
现在我只是在展示。如何从聪明的内容中只显示25个字符
答案 0 :(得分:11)
聪明地使用Truncate ......
<强> CODES 强>
{$articleTitle}
{$articleTitle|truncate}
{$articleTitle|truncate:30}
{$articleTitle|truncate:30:""}
{$articleTitle|truncate:30:"---"}
{$articleTitle|truncate:30:"":true}
{$articleTitle|truncate:30:"...":true}
{$articleTitle|truncate:30:'..':true: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...
Two Sisters Re..ckout Counter.
答案 1 :(得分:0)
如果安装了子串过滤器(我认为它已安装默认值):
{$myresult|substring:1:25}
如果没有,请查看此网站: