วิธีการสร้าง construct function ของ Smarty 3 และ 2 นั้นไม่เหมือนกัน
Smarty2 เขียนแบบนี้
require_once("Smarty.class.php");
Class Smarty2_Extended exntends Smarty {
function __construct() {
$this->Smarty();
$this->compile_dir = "yourpath/"; //path ใน Smarty ต้องปิดท้ายด้วย "/" เสมอ
$this->cache_dir = "yourpath/";
}
}
ส่วน Smarty3 ต้องใช้ parent::__construct();
require_once("Smarty.class.php");
Class Smarty3_Extended extends Smarty {
function __construct() {
parent::__construct();
$this->compile_dir = "yourpath/";
$this->cache_dir = "yourpath/";
}
}