I'm using Smarty template engine.
I'm doing a simple login page. I set a variabile named error with a message if there are some problems, but IF NOT I get:
Notice: Undefined index: error
How could I check if this variable exists?
I only do:
{if $error}<h1>{$error}</h1>{/if}
thanks
{assign var="name" value="Bob"} {assign "name" "Bob"} {* short-hand *} The value of $name is {$name}. The above example will output: The value of $name is Bob. {assign var="name" value="Bob" nocache} {assign "name" "Bob" nocache} {* short-hand *} The value of $name is {$name}.
{if} statements in Smarty have much the same flexibility as PHP if statements, with a few added features for the template engine. Every {if} must be paired with a matching {/if} . {else} and {elseif} are also permitted. All PHP conditionals and functions are recognized, such as ||, or, &&, and, is_array(), etc.
There you go!
{if isset($error)} {* TODO something *} {/if}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With