Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "./templates/diet-report.tpl" on line 3 "{if is_array($dietcontent) }" - Unexpected " }"' in ...
I did this:
{if is_array($dietcontent) }
There is something..
{else}
Noope...
{/if}
When i output {$dietcontent} i get "Array". But on pages where i dont get "Array" I wish to output a text.
Why am i getting error?
I even tried in my controller (this above is in template) :
$data['rapportExists'] = is_array($data['dietcontent']) ? true: false;
and then in my template:
{if $rapportExists == false }
noope
{/if}
Still receives the same error unexpected }
Arrays With Smarty Templatingphp' file will create the arrays and the '. tpl' file will be used for presenting the arrays within HTML. The easiest way to show how this can be done is to show you a sample '.
PHP function smarty_modifier_is_empty($input) { return empty($input); } ?> This will output Array is empty . Save this answer.
You need to remove the space before }
. Smarty will not permit whitespace before a closing brace, or after an opening brace. I tested this in some of my own templates and could reproduce your error by placing a space before the closing brace.
{if is_array($dietcontent) }
-------------------------^^^
{if $rapportExists == false }
---------------------------^^^
You can do it like:
{if $yourArray|is_array}
do something with it
{/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