Smarty USES strip_tags to filter HTML tags and truncate articles
- 2020-03-31 21:20:53
- OfStack
The strip_tags() function strips out HTML, XML, and PHP tags.
Smarty can remove HTML tags using strip_tags, including in < > Anything between.
Such as:
Index.php:
The index. The TPL:
Output results:
Article excerpt:
<?php echo strip_tags( " Hello <b>world!</b> " ); ?>
Smarty can remove HTML tags using strip_tags, including in < > Anything between.
Such as:
Index.php:
$smarty = new Smarty;
$smarty->assign( ' articleTitle', " Blind Woman Gets <span style= " font-family: &amp; " >New Kidney</span> from Dad she Hasn't Seen in <strong>years</strong>. " );
$smarty->display( ' index.tpl');
The index. The TPL:
{$articleTitle}
{$articleTitle|strip_tags}
Output results:
Blind Woman Gets <span style= " font-family: helvetica; " >New Kidney</span> from Dad she Hasn't Seen in <strong>years</strong>.
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.
Article excerpt:
{$article.content|truncate:35: "..." :true}