How to check if a boolean variable is 1 / true or 0 / false with TinyButStrong?

I'm a little new to TinyButStrong and I would like to know how I can check if a boolean variable is 0 or 1? For example, I have this:

$TBS->MergeBlock('tests', $tests); 

And $ tests have a variable call “activated”, which is logical. Thus, in my .docx document, I would like to write the line “Activated” if the variable is set to “True” (1) and “Inactive” if it is set to false (0).

What syntax should be used in a .docx document?

Thanks in advance.

+4
source share
1 answer

These are a few ways to format values ​​during merge, but by default, TBS converts data items to strings using an implicit PHP conversion.

Thus, true converted to '1', and false converted to '' (empty string).

For a nonexistent value: If the key in the array that you want to combine does not exist, you can avoid the TBS error message using the noerr parameter, and the replacement value is '' (empty string).

So your solution:

 [test.ativated;noerr;if [val]=1;then 'Activated';else 'non-activated'] 
+5
source

All Articles