Codeigniter + Dwoo

I had a problem implementing my CMS using Codeigniter 1.7.2 and Dwoo. I am using the Phil Sturgeon Dwoo library. My problem is that I want the user to create a template from the admin panel, which means that all templates will be saved in the database, including all variables and Dwoo functions. My questions:

  • Can I load a dwoo template from a database?
  • How to parse a dwoo variable or function from a database? I tried loading content from a database that includes dwoo var and a function inside it, and I tried to evaluate using the dwoo function eval()and phil sturgeon string_parse(), but still no luck.

, eg:

my controller

$data['header'] = "<h1>{$header}</h1>"; --> this could be loaded from database

$this->parser->parse('header',$data);

my opinion

{$header}

This error message is:

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined index:  header_title</p>
<p>Filename: compiled/805659ab5e619e094cac7deb9c8cbfb5.d17.php</p>
<p>Line Number: 11</p>

header_title - dwoo, .

,

+3
1

, , , , , . , .

, , :

// 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

{$header}, .

, CI, , .

+1

Source: https://habr.com/ru/post/1781966/


All Articles