Codeigniter + Dwoo Codeigniter + Dwoo codeigniter codeigniter

Codeigniter + Dwoo


It is definitely possible to do this, but for performance reasons it would probably be faster to store the templates as files on the filesystem, even if they're edited by users. If you're smart with file naming you can avoid most hits to the database.

Anyway, if you really want to do it with the database, the following should work:

// rendering the header$template = '<h1>{$header}</h1>'; // loaded from db, don't use double-quotes for examples or $header will be replaced by nothing$data = array('header' => 'Hello'); // loaded from db as well I assume$headerOutput = $this->parser->parse_string($template, $data, true); // true makes it return the output// now rendering the full page (if needed?)$data = array('header' => $headerOutput);$this->parser->parse('header', $data); // no 'true', so goes straight to output

The view would then contain {$header} and the output from the header template is passed to that variable.

Now I'm not sure how CI works so it might be better to just output the result of the first template and skip the second one entirely, but I'll leave that up to you.