在 smarty 中,我们可以使用它来缩短文本输出:
{$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.
我要显示的是:“ ... <a href="{$url}">read more</a>
”当您将其应用于代码时,它将是这样的:
{$articleTitle|truncate:30:"... <a href="{$url}">read more</a>":true}
但这不起作用。我怎样才能让它工作?