Q:

Transform smarty Boolean value to human readable value.('Yes'/'No' or 'True'/'False')

I'm using Smarty to generate some tables, and at one point I'm printing out variable values that have been passed from php file. The problem is that some of these variables are Boolean values and they render as "1" or "". This was my attempt to transform these Boolean values to a human readable format. It does not work. How can can I check if a variable is a Boolean value?
{if $val2.$value_index === true}Yes
{else if $val2.$value_index === false}No
{else}{$val2.$value_index->value}{/if}

A:

Use the PHP var_export() function as a smarty modifier for your boolean variables.
Set the second parameter to true, so var_export() returns the variable representation instead of outputting it.
To check if your variable is a boolean, use the PHP is_bool() function.
Your Smarty code should look like this:
{if is_bool($val2.$value_index)}
  {$val2.$value_index|var_export:true}
{/if}

A:

I'm not exactly familiar with this, but it looks as though that should be:
{if $val2.$value_index->value === true}Yes
{elseif $val2.$value_index->value === false}No
{else}{$val2.$value_index->value}{/if}

