The simplest and shortest method to check a variable

Tue. 20. March 2012 Snippets Nic
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 }

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.



Article was created by Nic

Nic

Nic is the founder and owner of www.templatemadesimple.com

We provide powerful templates with skins, tools and much more:
premium templates for CMS Made Simple



  • Twitter
« Back to Articles

Comments

Categories

Archive

From Twitter

I love CMSMS

Designed and developed by idea arts. I do this! © Copyright 2010-2013

Go back to Top