The simplest and shortest method to check a variable

If you are working with variables in smarty you know this procedure:

{if (isset($helloworld) && $helloworld != '')} 
    {$helloworld} 
{else} 
    helloworld does not exist
{/if}

But do you already know the default plugin? It works like a modifier.

The same stuff from above but much shorter:

{$helloworld|default:"helloworld does not exist"}

Or if you do not want to output an else statement:

{$helloworld|default:""}

This is also good to avoid internal Smarty warnings.

Comments