Categories > TinyButStrong general >

Conditional Display Problems

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Trent
Date: 2007-01-15
Time: 08:12

Conditional Display Problems

I'm creating a template that displays different data depending on the mode I set via a querystring.

http://www.mysite.com/city.php?act=go

Here is my php code I use to get the appropriate template data:

if (!isset($_GET)) $_GET=&$HTTP_GET_VARS ;
if (isset($_GET['act'])){
  $display_mode = $_GET['act'] ;
} else {
  $display_mode = 0 ;
}
if($display_mode = 'go'){
  $tpl = 'attractions.html'
  } elseif($display_mode = 'food'){
  $tpl = 'food.html'
  }else{
  $tpl = 'city_loc.html';
    }

And my HTML

[onload;file=[var.tpl]]

And of course the 2 errors I'm receiving when I try this:

TinyButStrong Error in field [var.tpl...] : the PHP global variable named 'tpl' does not exist or is not set yet. This message can be cancelled using parameter 'noerr'.

TinyButStrong Error in field [onload...] : the file '[var.tpl]' given by parameter file is not found or not readable. This message can be cancelled using parameter 'noerr'.

Now the file referred to in the second error does exist.  Somehow I'm not getting my variable $tpl to display.  Can somebody point out the error in my code?

I'm using the latest version of TBS also.
By: Skrol29
Date: 2007-01-15
Time: 18:49

Re: Conditional Display Problems

Hi,

The first message is probably because $tpl is a local variable, not a global variable. or perhaps is not set at all because the script do not run into the if() statement as you expect.

The second error message is simply because [var.tpl] is not merged so TBS tries to use it literally as a file name.
By: Trent
Date: 2007-01-15
Time: 21:02

Re: Conditional Display Problems

Thanks.  I'm not sure what I did, but I finally managed to make it work.  :)