Need smarty help :(

Soldato
Joined
28 Dec 2004
Posts
7,620
Location
Derry
Any of you clever buggers know a way to strip HTML tags using Smarty but still leave certain tags in place, i.e. I need to strip everything bar say, the <p> tags, I know you can strip all HTML using:

{!$result.fieldname|strip_tags:false}

And I know you can do what I need in PHP but I've not found anything allowing you to specify what fields to leave alone in Smarty, is it possible?

Cheers
 
strip_tags() has an optional field for tags to leave in, Smarty afaik can accept args for functions, so pass it the p tag.
 
Last time I used smarty (3 or more years ago) you could simply use {strip_tags|$var|'p'} (or may have been ':' and not '|' ) but it seems they have broken away from that ease of use (for good reason).

Code:
{php}
  echo strip_tags($var, 'p');
{/php}
will work.

However, it would be best for your application model to prepare the string before it hits the view.
 
Back
Top Bottom