I started working on a templates class, and the template info is stored in the db. Templates.Class.php: class Template { var $info = array(); function Template($template) { $file = "templates/$template.config.php"; if (file_exists($file)) { require($file); $this->info = new Temp(); //var_dump($this->info); //print_r($this->info); } else { echo "No Template: $template<br />File: $file"; } } function render_part($part) { //highlight_string($this->info->info22[$part]); if (array_key_exists($part, $this->info->info22)) { return $this->info->info22[$part]; } else { return "There is not template part '$part'"; } } } PHP: default.config.php (what is called when I call new Template(), just creates an array holding all the template info for the style 'default' class Temp { var $template_name; var $info22; function Temp() { $this->template_name = "default"; $info2 = mysql_query("SELECT * FROM templates WHERE tname = '$this->template_name'"); while ($t = mysql_fetch_array($info2)) { $this->info22[$t['tpart']] = $t['temp']; } //echo "\$this->info22[\$t['tpart']] = \$t['temp'];<br />"; return $this->info22; } } PHP: and just the bit in header.php that starts the whole thing: $basedir = "http://localhost/noc"; $gametitle = "Nation of Chaos - Beta - ".uNAME; $style_dir = "$basedir/style2.css"; require("classes/Template.Class.php"); $t = new Template("default"); require('init.php'); // just holds the $settings array eval("\$start = \$t->render_part(\"page_start\");"); echo $start; PHP: It loads up the code fine, but doesn't replace the variables, so it still echoes out: <head> <title>$settings['page_title']</title> Code (markup): ^^ the same as it is in the database. I've tried 144 ways to do it, but nothing will work for me. I've tried using eval too, since that worked on my last project, but no luck. Sorry for the extensive code, but if anyone can help me out i'd be very thankful
Try taking out the sinlge quotes out of the array brackets. <title>$settings[page_title]</title> Code (markup):
^^ Actually, it may does cause I had the same issue with a template system that I did some time ago... $test['yeah'] = 'Test'; echo "$test['yeah'] string "; // Doesn't work echo "$test[yeah] string "; // Works echo "{$test['yeah']} string "; // Works PHP:
Still nothing I tried checking the Mybb source (which is where I got the idea from) but that didn't help either.