Categories > TinyButStrong general >

Problem with sub-template

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Andrew
Date: 2005-08-23
Time: 16:58

Problem with sub-template

I try to make following:

<!--main.tpl-->
<table><tr>
<td>[var.type;onformat=get_news;subtpl]</td>
<td>[var.type;onformat=get_news;subtpl]</td>
</tr></table>
<!--main.tpl-->

Information in both <td> have the same design and use the same sub-template. The difference is 2 parameters - $count and $type.
Is it possible send those parameters in function get_news()?
Something like this:
<td>[type=2;count=10onformat=get_news;subtpl]</td>
<td>[type=3;count=20;onformat=get_news;subtpl]</td>

<!--get_news-->
function get_news($FieldName,&$CurrVal,&$CurrPrm,&$TBS){
$TBS->LoadTemplate('block.html');   
$TBS->MergeBlock('blockname',$GLOBALS['db_link'],'SELECT type FROM newstypes WHERE id_type='.$CurrVal);
$TBS->Show();
}
<!--get_news-->

<!--block.html-->
<p>[blockname.type;]</p>
<div>[newsblk.clock;block=div;headergrp=clock;encaps=2;frm='d mmmm yy';locale]</div>
<!--block.html-->
By: Skrol29
Date: 2005-08-23
Time: 18:00

Re: Problem with sub-template

Hello,

Yes you can.
Example :
<td>[onload;x_type=2;x_count=10;onformat=get_news;subtpl]</td>
<td>[onload;x_type=3;x_count=20;onformat=get_news;subtpl]</td>

function get_news():
function get_news($FieldName,&$CurrVal,&$CurrPrm,&$TBS){
$x_count = $CurrPrm['x_count '];
$TBS->LoadTemplate('block.html');
$TBS->MergeBlock('blockname',$GLOBALS['db_link'],'SELECT type FROM newstypes WHERE id_type='.$CurrPrm['x_type']);
$TBS->Show();
By: Andrew
Date: 2005-08-24
Time: 09:25

Re: Problem with sub-template

Big thanks!!!
It's work!!!