Categories > TinyButStrong general >

Mergeblock bigproblem

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: shadow
Date: 2004-02-07
Time: 14:30

Mergeblock bigproblem

Hello,

i use TBS 1.92 with ezsql

in php i have this:

$TPL->MergeBlock('block1',$db,"SELECT domain,user FROM domains WHERE user = '$username' AND rdomain = '1' ORDER BY domain");

and in templet ist only this:
<p>[block1.domain;block=p] / [block1.kunde;block=p]</p>

No data will display on output. wehn i make a mysql query then i have data in all var.

can any one help me?
By: shadow
Date: 2004-02-07
Time: 19:41

Re: Mergeblock bigproblem

in the header.php I include domain.php and in the header tpl I use
[tbs_include.onshow;file=[var.includedatei_html]]

in the domain.php only one php code :
$TPL2->MergeBlock('blk1',$db_local,"SELECT * FROM $sqltable_17");

and this only in the domain.tpl:
[blk1.server_ip]

all datas will be merge not the code in domain.tpl.

when i Use only var.xyz then work merge correct not with mergeblock or other merges....

Please help me i sit here over 6 hours on the problem....
By: Pirjo Posio
Date: 2004-02-07
Time: 21:36

Re: Mergeblock bigproblem

Hello shadow!

Have you somewhere before the MergeBlock a sentence like this?
$TBS->LoadTemplate('tbs_us_examples_datamysql.htm') ;
In stead of $TBS you should use the names $TPL and $TPL2.

I don't see kunde in your SELECT fields, so it can't be merged...
Is the server_ip set in your last SELECT with * or not?

Hope this helps.
- Pirjo
By: shadow
Date: 2004-02-07
Time: 22:18

Re: Mergeblock bigproblem

Sorry i have made many changes ojn my source for found the bug....
I use only one $TPL

By: shadow
Date: 2004-02-07
Time: 22:27

Re: Mergeblock bigproblem

I have use mergefield ('test', $var) and this is also not display in the output.

Can method merge not work in tbs_include???? when i use this in my tpl files.

in the moment i will make my project to the trash....:_(((((((

sorry for my bad english, i can my problem better explain in german
By: Pirjo Posio
Date: 2004-02-07
Time: 22:57

Re: Mergeblock bigproblem

In your second post you have:
[tbs_include.onshow;file=[var.includedatei_html]]

This will be automatically merged, if
in your .php file you have a variable $includedatei_html
and you call $TPL2->Show()

Here you still have TPL2, so that's why I used it.
Why do you in your SELECT use $db_local and not $db which
is a global variable set by EzSQL and used in TBS custom function for EzSQL?
Ich kann nicht Deutsch gut lesen/schreiben. Es ist unmöglich Dich auf Deutsch zu helfen. :-)
- Pirjo
By: shadow
Date: 2004-02-07
Time: 23:16

Re: Mergeblock bigproblem

i use 3 mysqls on 2 Server and so i can not use with one $db this is not my problem...

when i use [var.xyz] the merge all vars

when i use method merge.. this not to work

her the original code:
global.inc
--------cut-------------------
include_once ("include/config.inc.php");
include_once ("inc/classes/class.sql.php");
include_once ("include/function.inc.php");
include_once("inc/classes/tbs_class.php");
include_once ("inc/classes/class.phpurl.php");
include_once ("inc/classes/class.calendar.php");
include_once ("include/java.func.inc.php");

$db_local = new db($dbuser,$dbpass,$dbname,$dbhost);
$server = $db->get_row("SELECT * FROM $sqltable_17 WHERE server_id = '$sid_webserver'");

$TPL = new clsTinyButStrong ;
$calendar = new Calendar(date(d),date(m),date(Y),"ge");
$codep = new phpsecureurl ;
$codep->decode($aku);

$sid_webservername = $server->servername;
session_register('sid_webservername');
session_register('sid_webserver');
$db_server = new db($server->dbuser,$server->dbpass,$server->dbname,$server->dbhost);
include_once ("include/login.inc.php");
--------cut-------------------
header.php
--------cut-------------------
include ("include/global.php");
$includedatei = content($content,$sid_flag,$sitename,$sqltable_0);
$sitelogo = "images/$server->logo_path/". $sid_anbieter . ".jpg";
$webservername = $sid_webservername;
include("menu/menu_top.php");
$topmenu="templet/standard/menu_top.tpl";
include($menu);
$sitemenu = "templet/standard/$sitemenu";
include($includedatei);
$includedatei_html = "templet/standard/$web_tpl";
$helplink = $codep->encode("$session&h=$content");
$datum = $calendar->get_weekday_as_string().", ". date("d") .". " .$calendar-> get_month_as_string() ." " . date("Y");
$TPL->LoadTemplate('templet/standard/header.tpl');
$TPL->Show();
--------cut-------------------
header.tpl
--------cut-------------------
</td>
  </tr>
  <tr class="table-content">
    <td style="padding:10px" height="250" valign="top">[tbs_include.onload;file=[var.includedatei_html]]
  <tr class="table-content">
                <td style="padding: 10px; "></td>
              </tr>
            </table>
--------cut-------------------
domain.php
$TPL2->MergeBlock('blk1',$db_local,"SELECT server_ip FROM $sqltable_17");
--------cut-------------------
domain.tpl
<table>
    <tr>
        <td>[blk1.server_ip;block=tr]</td>
    </tr>
</table>
--------cut-------------------

when i user click on menu domain then use domain.php...

By: shadow
Date: 2004-02-07
Time: 23:17

Re: Mergeblock bigproblem

in domain.php is $TPL not $TPL2 sorry
By: shadow
Date: 2004-02-07
Time: 23:22

Re: Mergeblock bigproblem

when i use it in a normal php code with a single file then work very fine...

when i use this in my complicatet code then works this not ....

WHY?????????
By: Skrol29
Date: 2004-02-08
Time: 00:21

Re: Mergeblock bigproblem

Hi Shadow,

It's difficult to help you because we can't see when you create $TPL2.

Could you also describe what bad result you have. Is the table (<table>...</table>) with no row, or the table with the row not merged, or something else?

Do you have any TBS  error message?
By: shadow
Date: 2004-02-08
Time: 00:28

Re: Mergeblock bigproblem

hello,
i use only one $TPL (no one $TPL2)

i be cam no error message and in the website i see was i set in the TPL file [blk1.server_ip;block=tr] not more

the rest of my site is ok and i see it....

By: Pirjo Posio
Date: 2004-02-08
Time: 00:28

Re: Mergeblock bigproblem

Hi Skrol29 and shadow!

I think I understand now, what happens here. At least I hope so.
Shadow is reading the data directly with EzSQL and not with
custom TBS ezSQL functions explained in the TBS Support page.
He can do so, but then he has to read the data first in an array and then use in TBS Data Source Type "PHP Array Case-2" as explained in TBS manual.

Here's how I used it when testing, and it worked fine.

if ( $users = $db->get_results("SELECT res_name, res_score, res_date FROM t_tbs_exemples order by res_name",ARRAY_A) )
{
$TBS->MergeBlock('blk2',$users) ;
} else {
    echo ("No data found.");
}

- Pirjo
By: shadow
Date: 2004-02-08
Time: 00:33

Re: Mergeblock bigproblem

mergeblock with array also not work :-(((

no merge.. methode work with my site :-(

only i use single files and that is not good work with tmplets
By: shadow
Date: 2004-02-08
Time: 00:40

Re: Mergeblock bigproblem

i include my php files in php files and include the tpl file in tpl files

is that the problem???

or have any one a idee ..
By: Pirjo Posio
Date: 2004-02-08
Time: 00:41

Re: Mergeblock bigproblem

In your post where you sent all the code,
you say your first file is "global.inc" but in the header.php on the first line it's "global.php". Which one is true???

Maybe you just don't have something declared "global" so it can't be seen in the other place where you try to use it?

- Pirjo

By: Skrol29
Date: 2004-02-08
Time: 00:42

Re: Mergeblock bigproblem

Hi Shado, Hi Pirjo :) It's nice to read you :)

It's not normal that you can see the block source wile
$TPL->MergeBlock() has been called.
Could you have to test to make sure that the line with MergeBlock is well executed?
For example, add the fallowing line just before your $TPL->MergeBlock() line:
  echo '-> this message should appear the web page<br>' ;
By: shadow
Date: 2004-02-08
Time: 00:46

Re: Mergeblock bigproblem

i have cut the header file....

the global.inc is include in the header.php and so is all define ...
By: shadow
Date: 2004-02-08
Time: 00:49

Re: Mergeblock bigproblem

global.php is correct....

By: Pirjo Posio
Date: 2004-02-08
Time: 00:52

Re: Mergeblock bigproblem

Hope you noticed my answer, which is above your post here, because we sent them at the same time.

You should test print the array before merging with print_r to see if it contains the data you expect.
- Pirjo
By: shadow
Date: 2004-02-08
Time: 00:59

Re: Mergeblock bigproblem

i have use example
domain.php
$array_type1 = array('France'=>33, 'England'=>44, 'Spain'=>34, 'Italy'=>39, 'Deutchland'=>49) ;
$TPL->MergeBlock('blk1',$array_type1) ;
domain.tpl
<table width="300" border="1" align="center" cellpadding="2" cellspacing="0">
  <tr bgcolor="#CACACA">
    <td width="200"><strong>Country</strong></td>
    <td><strong>Prefix</strong></td>
  </tr>
  <tr bgcolor="#F0F0F0">
    <td>[blk1.key;block=tr]</td>
    <td>[blk1.val]</td>
  </tr>
  <tr bgcolor="#E6E6E6">
    <td>[blk1.key;block=tr]</td>
    <td>[blk1.val]</td>
  </tr>
</table>

Result:

<table width="300" border="1" align="center" cellpadding="2" cellspacing="0">
  <tr bgcolor="#CACACA">
    <td width="200"><strong>Country</strong></td>
    <td><strong>Prefix</strong></td>
  </tr>
  <tr bgcolor="#F0F0F0">
    <td>[blk1.key;block=tr]</td>
    <td>[blk1.val]</td>
  </tr>
  <tr bgcolor="#E6E6E6">
    <td>[blk1.key;block=tr]</td>
    <td>[blk1.val]</td>
  </tr>
</table>

By: Skrol29
Date: 2004-02-08
Time: 01:02

Re: Mergeblock bigproblem

Maybe you missed my previous post.
Are your sure that the line $TPL->MergeBlock(...) in domaine.php is executed?
By: shadow
Date: 2004-02-08
Time: 01:04

Re: Mergeblock bigproblem

hi...

say you wee can i see that is use...
By: Pirjo Posio
Date: 2004-02-08
Time: 01:06

Re: Mergeblock bigproblem

When I above said "declare global" I did not mean your global.php.
I meant "Do you use any functions where you should declare the global variables "global" so they will be seen outside your functions?"
Look at the PHP Manual, if needed.
- Pirjo
By: shadow
Date: 2004-02-08
Time: 01:11

Re: Mergeblock bigproblem

i have no var names "global" or what do you mean...

this complet site run without templet now I will and must new coding with templets...

By: Pirjo Posio
Date: 2004-02-08
Time: 01:22

Re: Mergeblock bigproblem

Skrol29 is very right when he said you should test print something to see where the problem lies.

In domain.php
$array_type1 = array('France'=>33, 'England'=>44, 'Spain'=>34, 'Italy'=>39, 'Deutchland'=>49) ;
$TPL->MergeBlock('blk1',$array_type1) ;

put the following line between these two lines:
print_r ($array_type1);

This tells you if the merging is done and also what goes in the merge.
- Pirjo

By: shadow
Date: 2004-02-08
Time: 01:27

Re: Mergeblock bigproblem

this is the result of print_f:

Array ( [France] => 33 [England] => 44 [Spain] => 34 [Italy] => 39 [Deutchland] => 49 ) 

and the table is not merge
By: Skrol29
Date: 2004-02-08
Time: 01:37

Re: Mergeblock bigproblem

Ok. So MergeBlock is effectivelly executed and the array is correct.

NOw, can you check that $TPL->LoadTemplate(...) is run **before ** $TPL->MergeBlock(...).

If MergeBlock is before LoadTemplate, then you merge no template.
By: shadow
Date: 2004-02-08
Time: 01:55

Re: Mergeblock bigproblem

hi,
i have recode the header.php so that the LoadTemplet now on the Top of file is...

<?
include ("include/global.php");
$TPL->LoadTemplate('templet/standard/header.tpl');
$includedatei = content($content,$sid_flag,$sitename,$sqltable_0);
$sitelogo = "images/$server->logo_path/". $sid_anbieter . ".jpg";
$TPL->MergeField('sitelogo',$sitelogo);
$TPL->MergeField('webservername',$sid_webservername);

include("menu/menu_top.php");
$TPL->MergeField('topmenu',"templet/standard/menu_top.tpl");
include($menu);
$TPL->MergeField('sitemenu',"templet/standard/$sitemenu");
include($includedatei);
$TPL->MergeField('includedatei_html',"templet/standard/$web_tpl");

$TPL->MergeField('header_icon',$header_icon);
$TPL->MergeField('header_titel',header_titel);
$TPL->MergeField('helplink',$codep->encode("$session&h=$content"));
$TPL->MergeField('datum',$calendar->get_weekday_as_string().", ". date("d") .". " .$calendar-> get_month_as_string() ." " . date("Y"));
$TPL->Show();
?>


Result in domain.php is not merge :-((((

the rest on site is ok and run
By: shadow
Date: 2004-02-08
Time: 02:11

Re: Mergeblock bigproblem

this: $TPL->MergeField('header_titel',header_titel);
will also not merge :-(((
By: Skrol29
Date: 2004-02-08
Time: 02:16

Re: Mergeblock bigproblem

Ok.

Could you replace the line
$TPL->MergeBlock('blk1',$array_type1) ;
with:
//$TPL->MergeBlock('blk1',$array_type1) ;
echo $TPL->Source ;
exit ;

This will display the state of the template when you try to merge the block. Check if the [blk1.*] tags are in the template at this state.

If is not, that exlains why the block is not merged, and you will have to understant why the sub-template is not merged at this state.

(I have to go to bed now, it's very late in France. I'll be back on your problem)
By: Pirjo Posio
Date: 2004-02-08
Time: 02:19

Re: Mergeblock bigproblem

I have not a solution to you, but some notes:
1. Read the PHP manual page http://www.php.net/function.include
as you don't see what I mean by "global".
2. Try using "require" instead of "include" so your code crashes if an included file is not found and you then know where the problem is.
3. If you use EzSQL together with TBS, you must use TBS array_type2 instead of array_type1.
4. On the following line:
$TPL->MergeField('header_titel',header_titel);
there should probably be $header_titel and not header_titel.

And now, Good Night!
- Pirjo