Categories > TinyButStrong general >

[var] fields does not show on sub script page.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Sean
Date: 2006-09-11
Time: 05:26

[var] fields does not show on sub script page.

I use TBS template calss both my main script and sub script, When I run the main script, the block on sub script can be shown normally, but the var field can't. It said:
"TinyButStrong Error in field [var.tmpsubvar...] : the PHP global variable named 'tmpsubvar' does not exist or is not set yet. This message can be cancelled using parameter 'noerr'. "


Original Code and Html:

------------main.php----------------
<?php
  include_once ('tbs_class.php') ;
  $subsptname='sub.php';
  $TBS = new clsTinyButStrong ;
  $TBS->LoadTemplate('main.htm') ;
  $TBS->Show() ;
?>
------------main.html----------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;">
<title>notilte</title>
</head>
<body>
[var.subsptname;script=[val];subtpl]
</body>
</html>

------------sub.php----------------
<?php
  $tmpsubarray[] = array('id'=>'1111', 'name'=>'Mary') ;
  $tmpsubarray[] = array('id'=>'2222', 'name'=>'Mike') ;
  include_once ('tbs_class.php') ;
  $tmpsubvar='Hello world';
  $TBS = new clsTinyButStrong ;
  $TBS->LoadTemplate('sub.htm') ;
  $TBS->MergeBlock('blk1',$tmpsubarray) ;
  $TBS->Show(true) ;
?>

------------sub.html----------------

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;">
<title>notile</title>
</head>
<body>
[var.tmpsubvar]
<br>
<table width="50%" border="0" align="left" cellpadding="1" cellspacing="1" class="text">
  <tr bgcolor="#CACACA">
    <td width="10" style="max-width:inherit"><strong>ID</strong></td>
    <td width="60"><strong>Name</strong></td>
  </tr>
  <tr bgcolor="#F0F0F0">
    <td width="10" style="max-width:inherit">[blk1.id;block=tr]</td>
    <td >[blk1.name]</td>
  </tr>
  <tr bgcolor="#E6E6E6">
    <td width="10" style="max-width:inherit">[blk1.id;block=tr]</td>
    <td style="max-width:inherit">[blk1.name]</td>
  </tr>
  <tr bgcolor="#FFCFB9">
    <td colspan="2">[blk1;block=tr;nodata]There is no data. </td>
  </tr>
  <tr>
    <td>&nbsp; </td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>
By: Skrol29
Date: 2006-09-11
Time: 11:33

Re: [var] fields does not show on sub script page.

Hi sean,

This is because your variable is locale (not global) when the script is called as a subscript. This is expained in the manual at "parameter script".
By: Sean
Date: 2006-09-11
Time: 12:05

Re: [var] fields does not show on sub script page.

thank you Skrol29

I have moved the variable in the sub script to the main script, It is OK now.