Categories > TinyButStrong general >

Condition if with empty then and else variables

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: bunak
Date: 2006-06-27
Time: 09:30

Condition if with empty then and else variables

TBS 3.0

I have this construction:
<legend>[onshow;if [var.txtLang]='en';then [var.FileType];else [var.FileTypeCS]] [var.txtFiles]</legend>
it returtns INBOUND FILES or OUTBOUND FILES when variable FileType and FileTypeCS are sets to values OUTBOUND/INBOUND or czech ekvivalent.

But when this both variables are empty (it meand borh file types) i'll get result: 1 FILES

Please help me where is problem
Thanks
Bunak
By: Skrol29
Date: 2006-06-27
Time: 10:00

Re: Condition if with empty then and else variables

Hi Bunak,

[onshow] tags are processed during the Show() method. You should check that your global variables $txtLang and $txtLangCS have not a value '1 FILES' at this moment.
To do so, I usually add a debog line like:
   echo "{".$txtLang."}{".$txtLangCS."}";
just before the line:
   $TBS->Show();
By: bunak
Date: 2006-06-27
Time: 13:16

Re: Condition if with empty then and else variables

I chcecked all variables txtLang, FileType, FileTypeCS and txtFiles before Show.
result is:
txtLang  contain en or cs, depending on selected language
FileType and FileTypeCS  are empty
txtFiles  contain text FILES or SOUBORY, depending on selected language

but result of construction is still
1 FILES or 1 SOUBORY, depend on language
By: Skrol29
Date: 2006-06-27
Time: 16:39

Re: Condition if with empty then and else variables

Hi Bunark,

I connot see any reason why TBS may arbitrarily display 1 instead of $FileType or $FileTypeCS.
If you could send to me a piece of your application that can reproduce the problem, I will search for the bug.
By: bunak
Date: 2006-06-29
Time: 10:43

Re: Condition if with empty then and else variables

Hi Skrol29,

I found the problem.

In submodule I was using construction
$TBS->MergeSpecial('var');
return $TBS->Source;
to return partial result to main template

Now I try construction
$TBS->Show(TBS_NOTHING);
return $TBS->Source;
and all is OK

Thanx for Your help.
Bunak