how to organize myself to wrap templates ?

A general technical discussion area for patTemplate.
Locked
wene
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 203
Joined: Sat Aug 20, 2005 1:40 am
Location: south of France

how to organize myself to wrap templates ?

Post by wene » 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 :

Code: Select all

    classname::function();
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 ) {
	default:
	case 'a':
	    subcomp1Screens::a ();
            subcomp2Screens::c ();
	break;
    //...........
}
and

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' );
    }
}
and

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>
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 :

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...
Last edited by wene on Mon Nov 14, 2005 1:58 am, edited 1 time in total.

wene
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 203
Joined: Sat Aug 20, 2005 1:40 am
Location: south of France

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

Post by wene » Thu Oct 27, 2005 9:50 pm

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

wene
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 203
Joined: Sat Aug 20, 2005 1:40 am
Location: south of France

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

Post by wene » Fri Oct 28, 2005 10:42 pm

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 ?

User avatar
Predator
Joomla! Ace
Joomla! Ace
Posts: 1827
Joined: Wed Aug 17, 2005 10:12 pm
Location: Germany-Bad Abbach
Contact:

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

Post by Predator » Fri Oct 28, 2005 11:00 pm

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.
Last edited by Predator on Fri Oct 28, 2005 11:51 pm, edited 1 time in total.
The "Humor, Fun and Games" forum has  more than 2500 Posts, so why not build a "Humor, Fun and Games Working" Group?
.....
Malicious tongues say we have this WG right from the start, they call it core team :D

wene
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 203
Joined: Sat Aug 20, 2005 1:40 am
Location: south of France

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

Post by wene » Fri Oct 28, 2005 11:47 pm

:)

wene
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 203
Joined: Sat Aug 20, 2005 1:40 am
Location: south of France

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

Post by wene » Sat Oct 29, 2005 9:13 pm

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.....

:)
Last edited by wene on Mon Nov 14, 2005 4:37 pm, edited 1 time in total.

wene
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 203
Joined: Sat Aug 20, 2005 1:40 am
Location: south of France

Re: how to organize myself to wrap templates ?

Post by wene » Mon Nov 14, 2005 2:03 am

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 :
http://arketec.com/index.php?option=com ... 6&Itemid=1

so now, im playing with parseintovariable

it looks better


Locked

Return to “patTemplate”