Categories > TinyButStrong general >

When and If error?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: B52
Date: 2005-12-07
Time: 21:39

When and If error?

Hi,
when i want to give some vars in condition, it doesnt work
i just do [var.foo;when [var.bla]=1]
but it doesnt work, it is always displayed
too when i do [var.foo;if [var.bla]=1;then '']
but why?
By: Skrol29
Date: 2005-12-08
Time: 17:08

Re: When and If error?

Hello,

Parameter "when" works only for blocks. You can put it in a Fields tag but only if your are using the simplified syntax (Block + Fields defined in only 1 tag). Otherwise, it is simply ignored.

[var.foo;if [var.bla]=1;then ''] should work, but TBS has a strange behavior due to historical features : "then" without "else "will return an empty result if the condition is false.

This will probably change in TBS 3.0
By: B52
Date: 2005-12-10
Time: 15:12

Re: When and If error?

It dosnt work!
i merge it as block he doesnt recognize if or when
By: Skrol29
Date: 2005-12-10
Time: 15:25

Re: When and If error?

Can you give a snippet more detailed of what you've tried and what result you have?
By: B52
Date: 2005-12-10
Time: 16:06

Re: When and If error?

Here is the PHP-Code
$tmp = explode("/", $_GET['site']);
$site = $tmp[0];
$arrayIndex[] = array("wasserzeichen" => "img/atm_28.png", "siteSrc" => "src/".$arraySiteSrc[$site]);

$tplIndex = new clsTinyButStrong;
$tplIndex->LoadTemplate($tplIndexSrc);
$tplIndex->MergeBlock('blk_index', 'array', 'arrayIndex');
$tplIndex->Show();

and here the HTML code
[blk_index.wasserzeichen;when [blk_index.siteSrc]!='kontakt']
By: Skrol29
Date: 2005-12-11
Time: 21:24

Re: When and If error?

Hello,

In the Html Code you've given, the TBS tag is not a Block Tag. A block Tag defines a block section, and therefor must have a parameter "block=".

Your tag is a Field tag linked to the block "blk_index" block. This mean it will display a value provided by the merging of this block. Because it is a single Field tag, and not a Block tag, parameter "when" is simply ignored when it is merged.

* Parameter "if" => conditional statement for TBS Field. The value of the Field is changed according to the condition is true or false.
* Parameter "when" => conditional statement for a TBS Block. The section is displayed or not according to the condition is true or false.
By: Anonymous
Date: 2005-12-11
Time: 23:58

Re: When and If error?

    <div id="logout">
        <!-- [onload;block=div;when [var.boolLoginLogout]=1;comm] -->
        <h1>logOut</h1>
        <table style="width:90%; text-align:center;">
            <tr>
                <td>Angemeldet als:<br />
                    [var._SESSION.Username;htmlconv=no]</td>
            </tr>
            <tr>
                <td>Letzter Besuch: [var._SESSION.lastvisited]</td>
            </tr>
            <tr>
                <td>
                    <input name="logOut" type="button" value="logOut" onclick="location='/logout.php'" />
                </td>
            </tr>
        </table>
    </div>
That's how it works for me. You should be able to use it similar to this.
By: neverpanic
Date: 2005-12-12
Time: 00:00

Re: When and If error?

Sorry, forgot my name and email, you never know...