how to organize myself to wrap templates ?
Posted: Thu Oct 27, 2005 6:15 pm
hello
i would like to make a component using patTemplate.
i have created sub programs to do what i need.
this component already works without patTemplate.
i have separated the sub programs in files.
i dont create objects but i use classes to pack functions.
i call different progs by using :
i try to understand patTemplate, and i have played with conditions and overlib tabpanes.
i rewrote my sub programs with patTemplate and they work fine on stand alone.
my prob is :
- how to organize my logic and html to run different templates inside one ?
i use the following code, but they appear one after the other, and i would like to create a "master" template to call them :
and
and
every sub program has different screens so i have different files with class.
like :
main_comp_folder
task_routing_file
sub_comp1_folder
subcomp1file containing subcomp1Screens
tmpl_folder
a.html
b.html
sub_comp_2_folder
the same....
im a hobbyist and i dont know how to organise myself to make the sub comps work together.
i have tried :
the template appears but the values are not computed.
if someone has an idea and time to answer...
i would like to make a component using patTemplate.
i have created sub programs to do what i need.
this component already works without patTemplate.
i have separated the sub programs in files.
i dont create objects but i use classes to pack functions.
i call different progs by using :
Code: Select all
classname::function();
i rewrote my sub programs with patTemplate and they work fine on stand alone.
my prob is :
- how to organize my logic and html to run different templates inside one ?
i use the following code, but they appear one after the other, and i would like to create a "master" template to call them :
Code: Select all
switch( $task ) {
default:
case 'a':
subcomp1Screens::a ();
subcomp2Screens::c ();
break;
//...........
}
Code: Select all
class subcomp1Screens {
function &createTemplate( $bodyHtml='') {
global $mosConfig_absolute_path, $itemid;
require_once( $mosConfig_absolute_path . '/includes/patTemplate/patTemplate.php' );
$tmpl =& patFactory::createTemplate( '', false, false );
$tmpl->setRoot( dirname( __FILE__ ) . '/tmpl' );
$tmpl->readTemplatesFromInput( $bodyHtml );
$tmpl->addGlobalVar('body','itemid',$itemid);
return $tmpl;
}
function a (){
global $database,$itemid;
$id = intval( mosGetParam( $_REQUEST, 'id', 0 ) );
if (id){
$database->setQuery( "SELECT * FROM #__table WHERE id='$id'");
$rows = $database->loadObjectList();
}
$tmpl =& mycompScreens::createTemplate( 'a.html' );
$tmpl -> addObject( 'rows', $rows, 'row_' );
$tmpl->displayParsedTemplate( 'sub1' );
}
}
Code: Select all
<mos:tmpl name="sub1">
<table>
<mos:tmpl name="rows">
<tr>
<td>{ROW_X}</td>
<td>{ROW_Y}</td>
</tr>
</mos:tmpl>
</table>
</mos:tmpl>
like :
main_comp_folder
task_routing_file
sub_comp1_folder
subcomp1file containing subcomp1Screens
tmpl_folder
a.html
b.html
sub_comp_2_folder
the same....
im a hobbyist and i dont know how to organise myself to make the sub comps work together.
i have tried :
Code: Select all
<mos:tmpl name="include_sub2" src="../../sub2/tmpl/a.html" parse="on"/>
if someone has an idea and time to answer...