Categories > TinyButStrong general >

A weird bug when code construction present

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Preben H
Date: 2012-03-09
Time: 10:24

A weird bug when code construction present

Hi all

I'm having a weird bug. This construction works with TBS for PHP4 but not when using the newest stable TBS for PHP5. What is wrong in the following:
      [onload; if [var._SESSION.user.country_ptr] != null; then
        [onload; if [var._SESSION.user.country_ptr.preferred_currency] == 'dkr'; then '<tr><td class="bold">Pris (kr.)</td><td class="rightdata">[product.price_dkr]</td><td> </td></tr>']
        [onload; if [var._SESSION.user.country_ptr.preferred_currency] == 'euro'; then '<tr><td class="bold">Pris (euro)</td><td class="rightdata">[product.price_euro]</td><td> </td></tr>']
        [onload; if [var._SESSION.user.country_ptr.preferred_currency] == 'nok'; then '<tr><td class="bold">Pris (nok.)</td><td class="rightdata">[product.price_nok]</td><td> </td></tr>']
        [onload; if [var._SESSION.user.country_ptr.preferred_currency] == 'sek'; then '<tr><td class="bold">Pris (sek.)</td><td class="rightdata">[product.price_sek]</td><td> </td></tr>']
      ]

The "TBS->LoadTemplate()" stops all execution when the above is present in the file.

What is wrong and how can I change the above to work with PHP5!
By: Skrol29
Date: 2012-03-09
Time: 11:36

Re: A weird bug when code construction present

Hi,

I've tested you snippet with TBS 3.8.0 and PHP 5.3.5 and I had no problem.
You should check your script to found where exactly the code is stopping. It may be not TBS.

By the way, while your code is working, it would be better to use conditional sections instead of if/then.

Here is my script for the test:
<?php

session_start();

$user = array(
    'country_ptr' => array('preferred_currency'=>'euro'),
);
$_SESSION['user'] = &$user;

include('tbs_class.php');
$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('test.html');
$TBS->Show();

By: Preben H
Date: 2012-03-09
Time: 12:24

Re: A weird bug when code construction present

When I remove those lines of code from my template, everything is working!

However, when I add those lines I have issues. I use php 5.2 and TBS 3.8.0

I've set up error reporting in php to all errors, and still nothing in output. By monkey "debugging" I know that the code stops whenever I call "TBS->LoadTemplate()" (by monkey-debugging)!


Regards

Preben
By: Rudy
Date: 2012-03-09
Time: 14:56

Re: A weird bug when code construction present

Works for me too. Guess the following would do the same what you're trying to achieve, try this:

<tr>[onload;block=tr;when [var._SESSION.user.country_ptr.preferred_currency] ~= /(dkr|euro|nok|sek)/;noerr]
  <td class="bold">Pris ([var._SESSION.user.country_ptr.preferred_currency;noerr])</td>
  <td class="rightdata">[product.price_[var._SESSION.user.country_ptr.preferred_currency;noerr]]</td>
  <td> </td>
</tr>

hth,
Rudy