Categories > TinyButStrong general >

"when" doesn't work as expected?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: n3wb13
Date: 2010-10-07
Time: 16:38

"when" doesn't work as expected?

Hello, I'm new to TBS and I'm having problem with it. Here is my PHP code

<?
require_once("config.php");

$TBS =& new clsTinyButStrong ;
$TBS->LoadTemplate("test.html");
$Message = "";
$TBS->Show();

And my HTML code

<table>
<tr><td>[onshow_message;block=tr;when [var.Message]!=""][var.Message]</td></tr>
</table>

I mean if the $Message is empty then delete the "tr" element, however, if
- $Message = "" then I get
<table>
<tr><td></td></tr>
</table>

- $Message = "Something"  then I get
<table>
<tr><td>Something</td></tr>
</table>

- global $Message then TBS gives me error

<br /><b>TinyButStrong Error</b> in field &#91;var.Message...] : the PHP global variable named 'Message' does not exist or is not set yet. <em>This message can be cancelled using parameter 'noerr'.</em><br />
<br /><b>TinyButStrong Error</b> in field &#91;var.Message...] : the PHP global variable named 'Message' does not exist or is not set yet. <em>This message can be cancelled using parameter 'noerr'.</em><br />
<table>
<tr><td>[var.Message]</td></tr>
</table>

So what's wrong with my code. Please I need your help. Thanks.
By: n3wb13
Date: 2010-10-07
Time: 18:00

Re: "when" doesn't work as expected?

OK It's so happy that after searching for a while all my problems are solved :)
By: Mike
Date: 2010-10-08
Time: 13:03

Re: "when" doesn't work as expected?

Hi, a have also some problem with "when":

I want to add DIV when some var is not null, well I add:
[onload;block=div;when [var.varname]!='']

and everything is ok when eg varname="aaa bbb ddfd"...
but when the variable is an equal sign "=" eg varname="aaa bbb = ddfd" - block is not appear?

anyone know what I should do?
thanks for your help

By: Skrol29
Date: 2010-10-10
Time: 15:57

Re: "when" doesn't work as expected?

Hi,

This is because TBS analyses the final expression. i.e. aaa bbb = ddfd!=''
You can try:
[onload;block=div;when ''!=[var.varname]]
It should work better.

Or even:
[onload;block=div;when '[var.varname]'!='']