Categories > TinyButStrong general >

Newbie needs help - Conditional

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: PG
Date: 2004-12-21
Time: 19:02

Newbie needs help - Conditional

Hi,

I have a simple template I would like to use with a condition, but I could not come up with a working solution, yet.

Here is my situation: I would like to display a block (array) if a variable is greater than 1, otherwise, do not display nothing.

I know it's trivial for you guys, but I've not figure it out, yet....

THANKS!

By: Skrol29
Date: 2004-12-22
Time: 03:07

Re: Newbie needs help - Conditional

With TBS 2.0
<table>
  <tr><td>
     [onshow;block=table;when [var.myvariable]+-1]
  </td></tr>
</table>

Operators are quite specific in order to not use special Html char.
Ther are detailed at the parameter 'when' for blocks in the manual.
By: Jann
Date: 2005-01-17
Time: 20:10

Re: Newbie needs help - Conditional

Sorry but when i want to check if a variable exists, can i write this way?
<table>
  <tr><td>
     [onshow;block=table;when [var.myvariable]]
  </td></tr>
</table>

Thanks.
By: Skrol29
Date: 2005-01-17
Time: 20:17

Re: Newbie needs help - Conditional

No. When the variable is not set then the Var field returns an error. You can avoid this error using parameter 'noerr', then the value of the field is an empty string.

So your block can be:
<table>
  <tr><td>
     [onshow;block=table;when [var.myvariable;noerr]!='']
  </td></tr>
</table>
By: Jann
Date: 2005-01-18
Time: 15:27

Re: Newbie needs help - Conditional

Wow! Nice move my friend.
That template engine really worth the name.

Merci beaucoup!