Page 1 of 1

Dashboard and multiple queries

PostPosted: Fri Jan 21, 2011 2:58 pm
by jamesb
I'm building a dashboard for my app and want to display several select elements from different tabels.

How can I pass multiple results to one page?

Thanks in advance.

Re: Dashboard and multiple queries

PostPosted: Fri Jan 21, 2011 3:05 pm
by shannah
The df_display() method takes 2 parameters. The first is an associative array of variables to be sent to the template for use.

e.g.
Code: Select all
$context = array(
    'foo'=> 'The Foo Value',
    'bar' => array('firstname'=>'Steve', 'lastname'=>'Hannah')
);
df_display($context, 'my_template.html');


Then in my template :
Code: Select all
<p>The Foo value is {$foo}.</p>
<p>Hello {$bar.firstname} {$bar.lastname}</p>



This would render like:
Code: Select all
<p>The Foo value is The Foo Value</p>
<p>Hello Steve Hannah</p>



Extrapolating from this, you can see that if you have multiple database results stored in arrays, you could just pass them both to the template context in their own variables.

Re: Dashboard and multiple queries

PostPosted: Sat Jan 22, 2011 3:01 pm
by jamesb
Thanks! I knew it must be something simple like that. That is just what I needed. :)

-james