Categories > TinyButStrong general >

newbie: Accessing local var of subtemplate from HTML

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: tonier
Date: 2008-05-22
Time: 03:23

newbie: Accessing local var of subtemplate from HTML

Please forgive me if it reposts..

Hi, I’m a new fan of TBS and I would say thanks for TBS that is really a wonderful tool to faster my web development process. But I have a silly question about accessing variable that declared in sub template from HTML. Just imagine if I have code like this..

-- global_var.php --
<?php
include_once(“class/tbs_class.php”);
$global_big_deal = “for whole night ..”;
?>

-- main.php  --
<?php
include_once(“global_var.php”);

$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('main.html');
$TBS->show();
?>

-- main.html –
<html><head></head>
<body>
[onload;script=’sub_template.php’;subtpl]
</body></html>

-- sub_template.php –
<?php
// for the simpler code I just post like this
$TBS =& $this;
// in here I can accessing global_big_deal
global $global_big_deal;
$global_big_deal = “mooo ….”;
// I want to declared my own in sub_template.php
$local_big_deal = “lalala…”;
$TBS->LoadTemplate(‘sub_template.html’) ;
$TBS->Show() ;
?>
Then I created one HTML page that accessed from sub_template.php, named sub_template.html

-- sub_template.html –
<html><head></head>
<body>
[var.global_big_deal]
[var.local_big_deal]
</body></html>

It will show error, $local_big_deal wasn’t set yet.
Isn’t it simpler if I can access local variable from sub_template.html? Cause it called from sub_template.php … Or it's my fault to learn about sub template theories :(

Sorry for my bad English ...
By: Skrol29
Date: 2008-05-24
Time: 18:38

Re: newbie: Accessing local var of subtemplate from HTML

Hi Tonier,

Local variables cannot be displayed by TBS. Only global variables.
This is true for subtemplates, or any other stuff that got by user functions.
By: tonier
Date: 2008-05-27
Time: 07:50

Re: newbie: Accessing local var of subtemplate from HTML

Thanks Skrol ...
TBS is really cool =)