Categories > TinyButStrong general >

Blockmerging in subtpl mode

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

Blockmerging in subtpl mode

First of all, sorry my english mistakes... I'm completelly out of pratice..

So... I'm developing a system and I'm using subtemplates to insert the header, the menu, the content and the footer. Everything was working fine until I have to make the menu work dynamically.

in my index page I have two combobox that are filled with values from the database:

INDEX.PHP
<?
include_once 'config.php'; // Mysql connection
include_once('tbs_class.php');

$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('html/index.html');
$sql = "SELECT `102000_1000`,`102000_6000` " .
    "FROM `s102000` " .
        "WHERE `102000_3000` = '1' " .
        "ORDER BY `102000_6000` ASC";
$TBS->MergeBlock('blk_tipo',$dbConexao,$sql);

$sql = "SELECT `103000_1000`,`103000_6000` " .
    "FROM `s103000` " .
        "WHERE `103000_3000` = '1' " .
        "ORDER BY `103000_6000` ASC";
$TBS->MergeBlock('blk_finalidade',$dbConexao,$sql);

$TBS->Show();
?>

?>

INDEX.HTML
<tr>
   <td width="130">Finalidade:</td>
   <td>
      <select name="txtfinalidade">
         <option value="[blk_finalidade.103000_1000;block=option]">[blk_finalidade.103000_6000]</option>
      </select>
   </td>
   <td>Tipo de Imóvel:</td>
   <td>
      <select name="txtTipo">
         <option value="[blk_tipo.102000_1000;block=option]">[blk_tipo.102000_6000]</option>
      </select>
   </td>
</tr>

This is working great. The problem happens now, with the dinamic content at the menu page:

INC_MENU.PHP
<?
include_once 'config.php'; // mysql connection

if (isset($this)) {
    $TBS =& $this;
} else {
    include_once('tbs_class.php');
    $TBS = new clsTinyButStrong;
}

$TBS->LoadTemplate('html/inc_menu.html');

$sql = "SELECT `101000_6000` FROM `s101000` ".
         "WHERE `101000_3000` = '1' ".
         "ORDER BY `101000_6000` ASC";

$TBS->MergeBlock('blk_menu',$dbConexao,$sql);
$TBS->Show();
?>

INC_MENU.HTML
<tr>
   <td class="fundo_menu_mark">&nbsp;</td>
   <td align="left" class="menu">
      <a href="#">[blk_menu.101000_6000;block=tr]</a>
   </td>
</tr>

With these codes, when I run the page I get the following error:
TinyButStrong Error when merging block [blk_menu] : unsupported variable type : 'NULL'.

I call the inc_menu.php page this way: [onload;script=inc_menu.php;subtpl]

So... the blocks merged at the index.php are working fine... but the menu doesn't... if I take out the block at the index, the menu works. It's like if there is some kind of conflict between the blocks. I've already tried to change the names of the variables and the blocks, but I've just got the same error.

You can see this running at http://www.icodz.com.br/projetos/transimoveisrio2/
To see the manu working, just click ate one of the topmenu links

Thanks for all the help you can provide me!
By: TomH
Date: 2006-09-11
Time: 21:42

Re: Blockmerging in subtpl mode

HI,
The error you get is the one I get whenever my db connection did not give a result. SO I would check to verify that you are getting a db result in the INC_MENU.PHP script

ALso - AFAIK you need to include your tbs_class and your connection script in the INC_MENU.PHP --

I cannot see what you have in your "config.php" file so I'm not sure what all you do there but I would try to do INC_MENU.PHP like this to test...
include_once 'config.php'; // Mysql connection
include_once('tbs_class.php');

$this->LoadTemplate('html/inc_menu.html');

$sql = "SELECT `101000_6000` FROM `s101000` ".
         "WHERE `101000_3000` = '1' ".
         "ORDER BY `101000_6000` ASC";

$this->MergeBlock('blk_menu',$dbConexao,$sql);
$this->Show();

Hope that helps a little,
By: Cleiver
Date: 2006-09-11
Time: 21:47

Re: Blockmerging in subtpl mode

config.php are the connection functions... mysql_connect and mysql_selectdb only...

I'm getting a db result... the two combos at index page are filled with data from the database....

And the menu works fine at the other pages that don't have the mergeblock function, like here (http://www.icodz.com.br/projetos/transimoveisrio2/quem_somos.php) for exemple...
By: TomH
Date: 2006-09-12
Time: 04:02

Re: Blockmerging in subtpl mode

I was talking about the db  nnection that is inside the INC_MENU.php file (NOT THE QUERIES IN THE INDEX FILE)

Cut and paste the actual index.php -and- index.html code that you are using.
By: Cleiver
Date: 2006-09-12
Time: 13:07

Re: Blockmerging in subtpl mode

INDEX.PHP
<?php
include_once 'config.php';
include_once('tbs_class.php');

$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('html/index.html');

$sql = "SELECT `102000_1000`,`102000_6000` " .
         "FROM `s102000` " .
         "WHERE `102000_3000` = '1' " .
         "ORDER BY `102000_6000` ASC";
$TBS->MergeBlock('blk_tipo',$dbConexao,$sql);

$sql = "SELECT `103000_1000`,`103000_6000` " .
         "FROM `s103000` " .
         "WHERE `103000_3000` = '1' " .
         "ORDER BY `103000_6000` ASC";
$TBS->MergeBlock('blk_finalidade',$dbConexao,$sql);

$TBS->Show();
?>

INDEX.PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="css/estilo.css" type="text/css" />
<title>Transimoveisrio</title>
</head>

<body>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td height="259" colspan="2" align="center">[onload;script=inc_topo.php;subtpl]</td>
  </tr>
  <tr>
    <td width="185" align="center" valign="top" bgcolor="#EDEDFE">[onload;script=inc_menu.php;subtpl]</td>
    <td width="575" valign="top" align="center">
    <!-- CONTEUDO -->
    <table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td width="27" align="left" valign="top"><img src="images/busca_de_imoveis.jpg" alt="" width="27" height="150" /></td>
        <td valign="top" align="right" width="523">
       
          <table width="515" border="0" align="center" cellpadding="1" cellspacing="2" class="cor_borda_tbl_index texto">
          <tr>
            <td width="130">Finalidade:</td>
            <td>
            <select name="txtfinalidade">
               <option value="[blk_finalidade.103000_1000;block=option]">[blk_finalidade.103000_6000]</option>
            </select>
            </td>
            <td width="130">Dormit&oacute;rio:</td>
            <td>
            <select name="select" class="texto">
              <option value="Loca&ccedil;&atilde;o">Loca&ccedil;&atilde;o</option>
            </select>            </td>
          </tr>
          <tr>
            <td>Tipo de Im&oacute;vel:</td>
            <td>
            <select name="txtTipo">
               <option value="[blk_tipo.102000_1000;block=option]">[blk_tipo.102000_6000]</option>
            </select>
            </td>
            <td>Vagas:</td>
            <td><select name="select" class="texto">
              <option value="Loca&ccedil;&atilde;o">Loca&ccedil;&atilde;o</option>
            </select></td>
          </tr>
          <tr>
            <td>Cidade:</td>
            <td><select name="select" class="texto">
              <option value="Loca&ccedil;&atilde;o">Loca&ccedil;&atilde;o</option>
            </select></td>
            <td>&Aacute;rea m&iacute;nima: </td>
            <td><select name="select" class="texto">
              <option value="Loca&ccedil;&atilde;o">Loca&ccedil;&atilde;o</option>
            </select></td>
          </tr>
          <tr>
            <td>Estado:</td>
            <td><select name="select" class="texto">
              <option value="Loca&ccedil;&atilde;o">Loca&ccedil;&atilde;o</option>
            </select></td>
            <td>Pre&ccedil;o:</td>
            <td><select name="select" class="texto">
              <option value="Loca&ccedil;&atilde;o">Loca&ccedil;&atilde;o</option>
            </select></td>
          </tr>
          <tr>
            <td>Bairro:</td>
            <td><input type="text" name="textfield" /></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td colspan="4" align="center"><input name="btn_enviar" type="submit" id="btn_enviar" value="Enviar" /></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td align="left" valign="top">&nbsp;</td>
        <td valign="top" align="right">&nbsp;</td>
      </tr>
    </table>
    <table width="550" border="0" cellspacing="0" cellpadding="0"  class="cor_borda_tbl_index texto">
      <tr>
        <td colspan="4"><img src="images/tit_destaque.jpg" alt="" width="548" height="28" /></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <!-- CONTEUDO -->
   
    </td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="center">[onload;script=inc_rodape.php;subtpl]</td>
  </tr>
</table>
</body>
</html>