Dashboard and multiple queries
Archived from the Xataface Users forum.
jamesb — Fri Jan 21, 2011 2:58 pm
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.
shannah — Fri Jan 21, 2011 3:05 pm
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>
Hello {$bar.firstname} {$bar.lastname}
`
This would render like:
- Code: Select all
- `<p>The Foo value is The Foo Value</p>
Hello Steve Hannah
`
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.
jamesb — Sat Jan 22, 2011 3:01 pm
Thanks! I knew it must be something simple like that. That is just what I needed.
-james