Question

I've just started learning the templating system Dwoo, and so far the basics are working (in regard to arrays).

However, I'm having trouble trying to get my pages to display content from a database. The official documentation has very little on it, as does Google.

What's your experience with Dwoo been like and has anyone on here tried this?

Was it helpful?

Solution

Dwoo is a templating engine, you shouldn't make database queries directly in it, it nullifies one of the main point of using a templating system.

You should make your database query in PHP:

$stmt = $pdo->prepare('SELECT * FROM table');
$stmt->execute();
$results = $pdo->fetchAll(PDO::FETCH_ASSOC);

Assign it to your template:

$dwoo = new Dwoo;
$dwoo->display('template.tpl', array('results'=>$results));

Then use it in the template:

{foreach from=$results item=result}
   do stuff
{/foreach}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top