TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

Subtemplate Help-me, SOS...

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Romulo
Date: 2012-10-25
Time: 02:04

Subtemplate Help-me, SOS...

My code

PHP Primary
<?php
include_once('../../includes/conexao.inc.php');
include_once('../../classes/tinybutstrong/tbs_class.php');

include_once('../../classes/tinybutstrong/plugins/tbs_plugin_html.php');
   
$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('html/chama_select.html');

$banco_de_dados = 'nacionalidades';

$TBS->Show();

?>

Html Primary

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <meta name="robots" content="noindex,nofollow" />
    </head>
    <body>

    <table border="1">
      <tr>
        <td style="background-color:#99CCCC">[onload;script=select.php;subtpl]</td>
      </tr>
    </table>


    </body>
</html>

PHP Subtemplate
<?php
include_once('../../includes/conexao.inc.php');
include_once('../../classes/tinybutstrong/tbs_class.php');

include_once('../../classes/tinybutstrong/plugins/tbs_plugin_html.php');

$query_nacionalidades = "SELECT id_unico ,descricao FROM $banco_de_dados WHERE status = 1 order by descricao";

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

$TBS->MergeBlock('bloco_nacionalidades',$conexao, $query_nacionalidades);

$TBS->Show();

?>

HTML Subtemplate
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="robots" content="noindex,nofollow" />
    </head>
    <body>
        <select name="">
            <option value="[bloco_nacionalidades.id_unico]">[bloco_nacionalidades.descricao;block=option]</option>
        </select>
    </body>
</html>

Explaining that I can not see any way to work:

The first script contains a variable with the name of the database that the data call from within the php subtemplate.

I'm going crazy with logic and nothing works!! Help me master Skroll

Thanks, Romulo
By: Romulo
Date: 2012-10-26
Time: 03:12

Re: Subtemplate Help-me, SOS...

possible and what I want?

I took my subtemplate adptei and to receive data by get. Alone it works well as a more subtemplate he n'ao wheel!! I need help!!...
By: Skrol29
Date: 2012-10-26
Time: 03:21

Re: Subtemplate Help-me, SOS...

>Alone it works well as a more subtemplate he n'ao wheel!! I need help!!...

This is because of your "$TBS = new clsTinyButStrong;" in the sub-script.
Doing this, it start a new merging and cancel the current one.

You should replace this line with:
if (isset($this)) {
  // We are under the TBS Subtemplate Mode => variables are local by default and the TBS object is referenced by variable $this.
  $TBS = &$this;
} else {
  // This sub-script can also be run under the normal mode => its corresponding template will be displayed like a main template.
  include_once('../../includes/conexao.inc.php');
  include_once('../../classes/tinybutstrong/tbs_class.php');
  include_once('../../classes/tinybutstrong/plugins/tbs_plugin_html.php');
  $TBS = new clsTinyButStrong;
}
By: Romulo
Date: 2012-10-29
Time: 00:16

Re: Subtemplate Help-me, SOS...

I did the modification recommended, but note that I have a variable in my php page and need to read this variable in my php template and I can not read this. Says that this variable empty, as I proceed now?

Thanks for your help and sorry to bother much.
By: Skrol29
Date: 2012-10-29
Time: 17:25

Re: Subtemplate Help-me, SOS...

Can't you use a global variale for it ?
By: Rromulo
Date: 2012-10-29
Time: 18:09

Re: Subtemplate Help-me, SOS...

not because depending on what happens on the main variable shall be delivered differently. So with subtemplate not I?
By: Skrol29
Date: 2012-10-29
Time: 22:19

Re: Subtemplate Help-me, SOS...

I'm sorry, I don't understand.

If you need to pass PHP information from the main script to th sub-script then you can use a global variable, or you can use VarRef (will replace global variables for merging [var] fields), or you can use ObjectRef.

http://www.tinybutstrong.com/manual.php#php_varref
http://www.tinybutstrong.com/manual.php#php_oop
By: Rromulo
Date: 2012-10-30
Time: 11:43

Re: Subtemplate Help-me, SOS...

Perfect, thank you again!! I managed to solve my problem!!

Now I run my forms according to what I have in the database!

For each subtemplate contains the syntax to generate the type of field.