2

I am writing a plugin, and everything is working fine so far. Some of my source data includes booleans. So I want to be able to test for a value of false. This is the plugin code.

$array = array('show_data' => 'FALSE');
$str = $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $array);

return $str;

and this is the template code:

{if not show_data}
   <p>This is some data</p>
{/if}

or

{if !show_data}
   <p>This is some data</p>
{/if}

But it won't work. Is this not supported or am I doing something wrong?

Currently I have this workaround

{if show_data}{if:else}
   <p>This is some data</p>
{/if}
1
  • What is the return value of $str when you want it to return false? You might need to return ''. – Johnathan Waters Dec 13 '13 at 20:59
2

ExpressionEngine interprets the returned value as the string "FALSE". You probably need to set your var like this:

$array = array('show_data' => '');

Or you need to format your if statement like

{if show_data == "FALSE"}
1

Please see my answer to your other related question which answers this too. (You need to set your vars array as a multidimensional array):

How to check for a boolean field?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.