Categories > TinyButStrong general >

Removing a part of block with a condition

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Preben Holm
Date: 2006-07-25
Time: 20:55

Removing a part of block with a condition

Let's say that a price is not to be shown unless a registered user is logged in a solution would be:
[product.price;when [var.login]=1]
(some way of reading a session variable $_SESSION['login']???)


but with a
<tr><td>Price</td><td>[product.price]</td></tr>

the only thing removed would be the price, and not the whole line - how to use a magnet like
condition instead of the variable remover?


Thanks,
Preben
By: Skrol29
Date: 2006-07-25
Time: 21:37

Re: Removing a part of block with a condition

Hi,

What is the element you want to remove ? The <td> , or only the text in the <td> ?
By: Preben Holm
Date: 2006-07-26
Time: 09:01

Re: Removing a part of block with a condition

The whole line starting from <tr> and ending with </tr>
By: NeverPanic
Date: 2006-07-26
Time: 12:08

Re: Removing a part of block with a condition

Removing the complete tr (might mess up your table layout):
<tr>[when [var.login]=1;block=tr]<td>Price</td><td>[product.price]</td></tr>
Removing tr's content:
<tr><td>Price</td><td>[when [var.login]=1;block=td+(td)][product.price]</td></tr>
By: Skrol29
Date: 2006-07-26
Time: 12:24

Re: Removing a part of block with a condition

Snippets of NeverPanic are ok but the tags [when...] should be [onlad;when...].

To display a session variable:
  [var._SESSION.login]
By: NeverPanic
Date: 2006-07-26
Time: 12:25

Re: Removing a part of block with a condition

Removing the complete tr (might mess up your table layout):
<tr>[onload;when [var.login]=1;block=tr]<td>Price</td><td>[product.price]</td></tr>
Removing tr's content:
<tr><td>Price</td><td>[onload;when [var.login]=1;block=td+(td)][product.price]</td></tr>

I'm sorry.
By: Preben Holm
Date: 2006-07-26
Time: 13:37

Re: Removing a part of block with a condition

So now, I decided only to remove the text (due to a rowspan), but why is the value shown by default:
[product.price;when [var.login]=1]

I don't understand - should "when" not work like this:
[onload;if [var.login]=1;then [product.price]]

(don't know if onload could be used)

Thanks.
By: NeverPanic
Date: 2006-07-26
Time: 18:09

Re: Removing a part of block with a condition

when and if/then/else are different in TBS. "when" works with blocks, while if/then/else does with single fields.

[var.login;if [val]=1;then '[product.price]']