Skip to content
Advertisement

Smarty: unset an array index in template

I would like to do {unset($array['index'])} into a Smarty 3 template.

Is such a syntax (or similar) supported ? After Googling and doc reading I can’t find something satisfying.

Maybe I should ask for a feature request to Smarty dev team ? 🙂

Anyway, how would you do this given the currently available template functions ?

Advertisement

Answer

I don’t think there’s a direct support for this in smarty. You can always do this with smarty’s {php} tag, however I would strongly discourage you from doing so. Logic doesn’t belong in a presentation-level template.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement