Page 1 of 1

how to organize myself to wrap templates ?

Posted: Thu Oct 27, 2005 6:15 pm
by wene
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

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 :

Code: Select all

switch( $task ) {
	case 'a':
	    subcomp1Screens::a ();
            subcomp2Screens::c ();

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 );
             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">
    <mos:tmpl name="rows">
every sub program has different screens so i have different files with class.
like :

            subcomp1file containing subcomp1Screens
            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"/>
the template appears but the values are not computed.

if someone has an idea and time to answer...

Re: [patTemplate] - how to organize myself to wrap templates ?

Posted: Thu Oct 27, 2005 9:50 pm
by wene
i have found a way.
i have separated the sql datas from the pattemplate engine.
i have now :
functions to get datas
functions to preformat html
html with template calling by src

Re: [patTemplate] - how to organize myself to wrap templates ?

Posted: Fri Oct 28, 2005 10:42 pm
by wene
not an answer i think.
im turning around.

i create a single pat objetct and i run my sub programs to feed it with all the screens datas.
then i call the screens with src attribute.

it works, but i dont think that it is the right solution.

because then, i wanted to create a "personal toolbar" to recall when i need (like tabs), and i cant reload it 2 times, so i tried the without success.
my head is upside down, but i have learned a lot during 3 days...

if someone has an idea ?

Re: [patTemplate] - how to organize myself to wrap templates ?

Posted: Fri Oct 28, 2005 11:00 pm
by Predator
Good to see that you have learned a lot, to help you and other more we have now created a patTemplate forum ( this her ;)  ) due to the fact that patTemplate becomes more important for the further developing and to help 3PD's to understand more about patTemplate and how to solve problems with patTemplate.

As you have seen this has started today so give us some days to get ready for you guys, believe me it got to get funny, i love patTemplate and you can do lots of things in a easy way.

Re: [patTemplate] - how to organize myself to wrap templates ?

Posted: Fri Oct 28, 2005 11:47 pm
by wene

Re: [patTemplate] - how to organize myself to wrap templates ?

Posted: Sat Oct 29, 2005 9:13 pm
by wene
in another thread, Alwarren told that its preferable to use patfactory.
so i went to read the patfactory class in templates.php.
i have seen there that joomla creates patfactory to load some variables and default templates.
then i understood where the tab panes come from and i tested others like the calendar...
i think that i will try to follow the same logic to build my sub components and toolbar.

to "call" my "toolbar", i just had to read the toolbar template from file BEFORE loading the main template.....


Re: how to organize myself to wrap templates ?

Posted: Mon Nov 14, 2005 2:03 am
by wene
i have past few days getting crazy with CALL SRC LINK ... trying encapsulating individuals conditionals templates. :)
then i remembered that i have seen an exemple on how to use patTemplates with arkcornerdemo : ... 6&Itemid=1

so now, im playing with parseintovariable

it looks better