[SOLVED]Result of a query in a list

A general technical discussion area for patTemplate.
Locked
DaesDemon
Joomla! Apprentice
Joomla! Apprentice
Posts: 37
Joined: Wed Nov 23, 2005 1:22 pm

[SOLVED]Result of a query in a list

Post by DaesDemon » Tue Jan 10, 2006 5:02 pm

Hi everyone,
I begin to try to use patTemplate for outputing my components, but i am in front of an error i don't understand:
My code is that:

Code: Select all

	$database->setQuery( $query );
	$records = $database->loadObjectList();
        
        $tmpl = &createTemplate();
        $tmpl->setAttribute( 'body', 'src', 'adminListe.tmpl.html' );
        $tmpl->addVar('body', 'table', $this->name );
        $tmpl->addRows( 'records', $records );
        
        $tmpl->displayParsedTemplate('form');
And i get
error Warning: array_change_key_case(): The argument should be an array in f:\www\joomla-dev\includes\patTemplate\patTemplate.php on line 791
I am sure i have missed something, but my $records is an array containing relationals array for each record, so it follow the documentation i found on addRows.

Could someone  give me a clue about this?
Last edited by DaesDemon on Tue Jan 10, 2006 6:58 pm, edited 1 time in total.

DaesDemon
Joomla! Apprentice
Joomla! Apprentice
Posts: 37
Joined: Wed Nov 23, 2005 1:22 pm

Re: First Try with patTemplate

Post by DaesDemon » Tue Jan 10, 2006 6:38 pm

Oki i change it with

Code: Select all

		$database->setQuery( $query );
		$records = $database->loadObjectList();
        
        $tmpl = & createTemplate();
        $tmpl->setAttribute( 'body', 'src', 'adminListe.tmpl.html' );
        $tmpl->addVar('body', 'table', $this->name );
        $tmpl->addObject( 'test', $records );
        
        $tmpl->displayParsedTemplate('form');
and my template is:

Code: Select all

<h1>Edition {TABLE}</h1>
<table border="1" cellpadding="1" cellspacing="">
    <tr>
        <th>Id</th>
        <th>Titre</th>
    </tr>
    <!-- template for list row -->
    <patTemplate:tmpl name="test" type="modulo" modulo="2">
    <tr>
        <td>{ID}</td>
        <td>{TITRE}</td>
    </tr>
    </patTemplate:tmpl>
</table>
But it don't display the list.

when i add the object to body instead of test , the iteration work correctly.
I probably miss something but i cannot figure what.

DaesDemon
Joomla! Apprentice
Joomla! Apprentice
Posts: 37
Joined: Wed Nov 23, 2005 1:22 pm

Re: First Try with patTemplate

Post by DaesDemon » Tue Jan 10, 2006 6:56 pm

Oki i get it, just replace patTemplate:tmpl  by mos:tmpl


Locked

Return to “patTemplate”