Proper way of printing variable only if exists, in .tpl smarty file

466 Views Asked by At

Is there any smart way to deal with "undefined" or "undefined index" while printing variables in .tpl files? I know I can check every time with

{if isset($variable.key(}
    {$variable.key}
{/if}

But doing it for every variable seems just kind of too much code for single variable. I know I could manage it in backend, but my frontend template is used on two slightly different backends, i.e. some variables will be just undefined as they are not needed. Maybe there is something like {$variable.key || null} ?

0

There are 0 best solutions below