CodeIgniter中使用Smarty3基本配置
(编辑:jimmy 日期: 2025/10/25 浏览:3 次 )
一、创建Smarty类库
1.将smarty的libs文件复制到libraries下(这里我重命名为smarty)
2.新建Cismarty.php文件。(符合文件规范,文件名的首字母和class名的首字母大写,但是控制器引用加载时,类名/文件名不需要大写)
Cismarty.php
<"system" folder
//APPPATH - The full server path to the "application" folder
class Cismarty extends Smarty
{
public function __construct()
{
parent::__construct();
$this->caching = false;
$this->setTemplateDir(APPPATH . 'views/Smarty/templates'); //设定所有模板文件都需要放置的目录地址。
$this->setConfigDir(APPPATH . 'views/Smarty/configs'); //设定用于存放模板特殊配置文件的目录,
$this->setCacheDir(APPPATH . 'views/Smarty/cache'); //在启动缓存特性的情况下,这个属性所指定的目录中放置Smarty缓存的所有模板
$this->setPluginsDir(APPPATH . 'views/Smarty/plugins'); //插件目录
$this->setCompileDir(APPPATH . 'views/Smarty/templates_c'); //设定Smarty编译过的所有模板文件的存放目录地址
}
}
"htmlcode">
<"name", 1200);
$this->cismarty->display('dd.tpl');
}
}
?>
也可以在application/config/autoload.php中配置自动加载资源。
下一篇:利用PHP脚本在Linux下用md5函数加密字符串的方法