I’ve got some problems when configuring smarty, version 3.1.12.
When I try to extract some data from database, it runs “Fatal error: Call to a member function createTemplate() on a non-object in F:…\smarty\sysplugins\smarty_internal_templatebase.php on line 47”
But if the program does NOT extract from database, it runs ok. For example:
<?php
include "smarty/smarty.class.php";
$smarty->assign('title', 'I'm title');
$smarty->assign('content', 'I'm content');
$smarty->display('test.html');
?>
Below is the codes I’m using.
inc.php
<?php
// Load smarty class file.
require("sys.smarty.php");
$smarty = new Smarti();
?>
sys.smarty.php
<?php
// Load smarty class file.
require("smarty/smarty.class.php");
class Smarti extends Smarty{
function Smarti() {
$this->setTemplateDir("../smarty/templates");
$this->setConfigDir("../smarty/configs");
$this->setCompileDir("../smarty/templates_c");
$this->setCacheDir("../smarty/cache");
}
}
?>
I don’t know where went wrong. I can extract data from database in some other way, so it’s not the database problem. Could u guys lend me a hand? Thx~
The
Smarty constructorsets a member variable to itself. Do it from theconstructorof your extendedSmarticlass.But it would be better to call the Smarty constructor itself.