CMSware-kTemplate安装使用
导航:返回上一页
kTemplate是思维(CMSware)开发组自主研发的编译模版引擎。kTemplate的语法和接口都接近Smarty,但是比Smarty更为简洁,由于是自有开发,所以维护、扩展更容易
kTemplate安装使用说明:
KTpL_DIR:模版引擎文件放置的目录
一般使用举例:
define('KTpL_DIR', '../include/lib/kTemplate');
define('SYS_path', './');
require(KTpL_DIR . 'kTemplate.class.php');function hello(&$string)
{
return $string;
}$TpL = new kTemplate();
$TpL->template_dir = SYS_path.'skin/admin/';
$TpL->compile_dir = SYS_path.'sysdata/templates_c/';
$TpL->registerparseFun('hello');
$TpL->assign('title',' 编译模版引擎');
$TpL->display('test.html');?>
缓存使用举例 :
define('KTpL_DIR', '../include/lib/kTemplate');
define('SYS_path', './');
require(KTpL_DIR . 'kTemplate.class.php');$TpL = new kTemplate();
$TpL->template_dir = SYS_path.'skin/admin/';
$TpL->compile_dir = SYS_path.'sysdata/templates_c/';
$TpL->cache_dir = SYS_path.'sysdata/cache/';
$TpL->cache_lifetime = 3600;
$TpL->client_caching =true;
$TpL->assign('title','编译模版引擎');
if(!$TpL->is_cached('test.html', $_GET['id'])) {
$TpL->display_cache('test.html', $_GET['id']);} else {
数据库连接....
逻辑处理...
$TpL->display_cache('test.html', $_GET['id']);}
?>