This article mainly introduces the annotation and truncation functions in Smarty. These two functions are not very commonly used in Smarty, but they are very practical. For more information, see
This article mainly introduces the annotation and truncation functions in Smarty. These two functions are not very commonly used in Smarty, but they are very practical. For more information, see
Note
The Code is as follows:
{* This is a single line of Smarty annotation from jb51.net, which is invisible in the source code of the webpage *}
{* This is a multiline
Smarty comments
Not sent to the browser
*}
Template comments are surrounded by asterisks and then surrounded by delimiters. Type: {* This is a comment *}. The Smarty annotation is not displayed in the output of the final template. The former is useful for inserting internal comments in the template, because no one can see it .; -)
Truncate
The Code is as follows:
$ Smarty-> assign ('hxtitle', 'two Sisters Reunite after Eighteen Years at Checkout Counter .');
Template:
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}
Output:
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 have to truncate it in PHP:
,