Categories > TinyButStrong general >

ifempty and if

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Phillip
Date: 2005-11-23
Time: 15:59

ifempty and if

I would like to display a conditional using the if statement, but be over-ridden using the ifempty. Is this possible? eg
[result.available;ifempty='';if [val]=1; then 'Feature is available'; else 'Feature not yet available']

The result comes from MySQL which can be NULL, 0 or 1. Is there any way of getting this working apart from using a hack such as a fake tag with a magnet? Thanks.

Phillip.
By: Skrol29
Date: 2005-11-23
Time: 16:33

Re: ifempty and if

Hello Phillip,

Parameter "if" is applied before "ifempty", and "ifempty" takes account of the modified value by "if".

But you can do it using embedded fields.
This is a bit bold, but should works.
[result.available;if [val]!='';then '[result.available;if [val]=1;then 'Feature is available';else 'Feature not yet available']']

By the way, I'm planning to make TBS supporting several parameter "if" in the same field.
By: Phillip
Date: 2005-11-23
Time: 17:02

Re: ifempty and if

This works perfectly. Wrapping it in a magnet looks neater in the source but of course peppers the output with useless tags. Putting in an 'elif' would be the neatest solution.