Categories > TinyButStrong general >

Handling multiple IF statements with TBS

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: worchyld
Date: 2004-07-07
Time: 17:42

Handling multiple IF statements with TBS

How do you do mulitple if statements with TBS, and combine the output with HTML?

This is my example, it does not output the email address link, or handle multiple if statements.  In addition, I could not find a 'end if' statement.

Thanks for your help.


[tbs_check; if [val.type]!='hidden';then
    [tbs_check; if [val.type]='email';then 'You can email: <a href="mailto:[var.person2_contact]">[var.person2_contact]</a>']
    [tbs_check; if [val.type]='phone';then 'You can phone: [var.person2_contact]']
;else
    'There are no contact details for [var.person2]'
]

By: Skrol29
Date: 2004-07-07
Time: 18:29

Re: Handling multiple IF statements with TBS

Hi Worchyld,

First remark: you've used [val.type] instead of [var.type].

But anyway, [tbs_check] tags without sub-names are processed as fields, and both [tbs_check] and [var] fields don't support self-embeded tags.

Here is a way to do what you need:
<table>
<tr><td>
   [tbs_check.visible;block=table;if [var.type]!='hidden']
   [tbs_check.msg;block=tr;if [var.type]='email']
   You can email: <a href="mailto:[var.person2_contact]">[var.person2_contact]</a>'
</td></tr>
<tr><td>[tbs_check.msg;block=tr;if [var.type]='phone']
    You can phone: [var.person2_contact]
</td></tr>
<tr><td>[tbs_check.msg;block=tr;else]
    There are no contact details for [var.person2]
</td></tr>
</table>

By: worchyld
Date: 2004-07-07
Time: 19:24

Re: Handling multiple IF statements with TBS

Thank you for your help.
By: worchyld
Date: 2004-07-07
Time: 19:27

Re: Handling multiple IF statements with TBS

How do I do it without tables?
By: worchyld
Date: 2004-07-07
Time: 20:08

Re: Handling multiple IF statements with TBS

Fixed it now,

<div class="contactPerson">
    <p>
        [tbs_check.visible;noerr;block=div; if [var.type]!='hidden']
        [tbs_check.msg;noerr;block=p;if [var.type]='email']
        You can email [var.person2] at the following e-mail address: <a href="mailto:[var.person2_contact]">[var.person2_contact]</a>
    </p>
    <p>
        You can telephone [var.person2] at the following telephone number: [tbs_check.msg;block=p;if [var.type]='phone']">[var.person2_contact]</a>
    </p>
    <p>
    [tbs_check.msg;block=p;else]
        There are no contact details for [var.person2].
        </p>
</div>

By: Skrol29
Date: 2004-07-08
Time: 00:49

Re: Handling multiple IF statements with TBS

Yes

You can also use:
  [tbs_check.visible;block=begin;...]
  ...
  [tbs_check.visible;block=end]