Reputation: 61
I am trying to add strip_tags exceptions for smarty but for some reason it is not working. below is my code. can someone help me figure out what I am doing wrong.
<td class="olotd4 tooltip2">
<span>{$customer_work_orders_result
[i].WORK_ORDER_DESCRIPTION|strip_tags:"<a><del><em><strong><blockquote>"|stripslashes}</span>
{$customer_work_orders_result[i].WORK_ORDER_SCOPE}</td>
it is working but stripping everything.
Thanks in advance..
Upvotes: 1
Views: 1193
Reputation: 3245
Smarty strip_tags implementation does not allow that. You can, however, write your own modifier:
save it as smarty/plugins/modifier.strip_tags_exclude.php (or in your custom plugins folder)
function smarty_modifier_strip_tags_exclude()
{
$params=func_get_args();
if (!isset($params[1])) {
$params[1] = true;
}
if ($params[1] === true) {
return preg_replace('!<[^>]*?>!', ' ', $params[0]);
} else {
if (is_string($params[1]))
{
$allowable_tags = strtr($params[1],'[]','<>');
}
return strip_tags($params[0],$allowable_tags);
}
}
and then you can use it this way:
{$variable|strip_tags_exclude:'<a><p><ul><li>'}
or alternatively (some editors may get confused and think that you're opening tags):
{$variable|strip_tags_exclude:'[a][p][ul][li]'}
Upvotes: 2