Smarty: unset an array index in template

Frosty Z picture Frosty Z · Sep 19, 2011 · Viewed 17.9k times · Source

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 ?

Answer

Aleks G picture Aleks G · Sep 19, 2011

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.