Annotation
Copy code The code is as follows:
{* This is a single-line Smarty comment from jb51.net, which cannot be seen in the source code of the web page*}
{* This is a multi-line
Smarty Notes
Not sent to the browser
*}
Template comments are surrounded by asterisks, followed by delimiters, such as: {* This is a comment *}. Smarty comments will not be displayed in the output of the final template, unlike this. The former is useful for inserting internal comments in templates where no one else can see them. ;-)
http://www.itlearner.com/code/smarty_cn/language.basic.syntax.html
Truncate
Copy code The code is as follows:
$smarty->assign('hxtitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
The template is:
Copy code The code is as follows:
{$hxtitle}
{$hxtitle|truncate}
{$hxtitle|truncate:30}
{$hxtitle|truncate:30:""}
{$hxtitle|truncate:30:"---"}
{$hxtitle|truncate:30:"":true}
{$hxtitle|truncate:30:"...":true}
{$hxtitle|truncate:30:'..':true:true}
The output is:
Copy code The code is as follows:
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.
You don’t need to intercept it in PHP: http://www.itlearner.com/code/smarty_cn/language.modifier.truncate.html