Categories > TinyButStrong general >

Problem TBS include JS-menu

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Rob
Date: 2004-02-17
Time: 08:59

Problem TBS include JS-menu

Hi,

I am using TBS, which works great.
Now I want to include a JS-menu which is fed by a MySql-database.
I get errors from the JS-script which is in the body of the html-file.
I tried everything with TBS file-include, etc. but I only get errors.
Could someone please help me!

My PHP looks like this:
<?PHP
include_once("tbs_class.php");
include_once("mysql_db.php");

$db_id = mysql_connect($db_srv,$db_usr,$db_pwd) ;
$db_ok = mysql_select_db($db_dbase,$db_id) ;
$ObjTBS = new clsTinyButStrong;

$doc = $_GET["doc"] ;

$ObjTBS->LoadTemplate("doc.htm");

$ObjTBS->MergeBlock("blk1",$db_id,"SELECT * FROM documenten WHERE menudoc=$doc");
mysql_close($db_id);
$ObjTBS->Show() ;
?>

The HTML looks like:
<?
//THIS PART OF PHP NEEDS TO BE HERE TO GET THE MENU STARTED: THE MENU IS FED BY MYSQL DATABASE
    $dbhost = "localhost";    // DB Host name
    $dbusername = "";     // DB User
    $dbpass = "";        // DB User password
    $dbname = "XXXXXX";     // DB Name
    $query = "select * from menu_hfd WHERE vrijgeven='Ja' ORDER BY volgorde";
    $connection = mysql_connect($dbhost, $dbusername, $dbpass);
    $resultCat = mysql_db_query($dbname, $query);
    $numrowsCat = mysql_num_rows($resultCat);
?>
<html>
<head>
<script type="text/javascript" language="JavaScript1.2" src="stm31.js"></script>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<script type="text/javascript" language="JavaScript1.2">;
<?
include "menu_cnt.php";
?>
</script>

<table width="100%" border="0">
  <tr>
    <td>
      <table width="100%" border="1">
        <tr>
          <td>[blk1.omschrijving;block=tr]</td>
        </tr>
      </table>
    </td>
  </tr>
</table>

</html>

The part in the body with <include "menu_cnt.php";> is the part that generates the errors.
When the TBS-statements are left out, the html works fine. When I leave the menu out, TBS works fine.

Thanks very much for your help.
Rob
By: Skrol29
Date: 2004-02-17
Time: 13:41

Re: Problem TBS include JS-menu

Hi Rob,

The Php code that is directly in the template will never be executed. It is considered as text.
To execute a specific piece of PHP code when a template is loaded or shown, you can use [tbs_include] tags with the parameter 'script'.
By: Rob
Date: 2004-02-17
Time: 13:53

Re: Problem TBS include JS-menu

Hi Skrol29,

Is the following completely replaced by the [tbs_include]?
<script type="text/javascript" language="JavaScript1.2">;
<?
include "menu_cnt.php";
?>
</script>
I tried that but I probably made a mess out of it.
I appreciate the correct format.

Thanks,
Rob
By: Skrol29
Date: 2004-02-17
Time: 16:50

Re: Problem TBS include JS-menu

No, the code <? ... ?> placed in the template is simply ignored.
To run a piece of script :
  [tbs_include.onload;script=menu_cnt.php]

If this script is supposed to display something :
  [tbs_include.onload;script=menu_cnt.php;getob]
By: barbie43
Date: 2004-12-27
Time: 17:06

Re: Problem TBS include JS-menu

Yes, in fact i have the same problem...
PLIZZZZZZZZ ! HEEEEEELP!!!!
By: Skrol29
Date: 2004-12-27
Time: 19:07

Re: Problem TBS include JS-menu

For TBS 2.0 or higher, use [onload] or [onshow] instead of [tbs_include]