最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Discuz 模板引擎的封裝類代碼

 更新時間:2008年07月18日 08:56:28   作者:  
需要使用Discuz的模板引擎,于是周未抽了點(diǎn)時間幫忙做了個封裝,測試了一下,速度還不錯。順便也拿來用到自己的程序中使用,歡迎大家下載并提出意見

主要功能說明

去掉了 Discuz 語言包的功能 
移植 Discuz 模板中所有的功能 
添加了自動更新緩存及生命周期功能 
在模板中的使用方法跟Discuz的一樣,所以就不做多余的說明了,使用前只需要做些簡單的設(shè)置就可以了

如果需要使用discuz的語言包功能,只要去掉template.class.php第172行注釋,并在template.func.php中加上discuz原來的languagevar函數(shù)就可以了

點(diǎn)擊下載源文件

以下是代碼范例:

/**
* 使用示例
*
* @copyright Copyright (c) 2007-2008 (http://www.tblog.com.cn)
* @author Akon(番茄紅了)
* @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
*/

require_once ('classes/template.class.php');

$options = array(
    template_dir' => 'templates/', //指定模板文件存放目錄
    'cache_dir' => 'templates/cache', //指定緩存文件存放目錄
    'auto_update' => true, //當(dāng)模板文件有改動時重新生成緩存 [關(guān)閉該項會快一些]
    'cache_lifetime' => 1, //緩存生命周期(分鐘),為 0 表示永久 [設(shè)置為 0 會快一些]
);
$template = Template::getInstance(); //使用單件模式實例化模板類
$template->setOptions($options); //設(shè)置模板參數(shù)

/*
// 可以使用以下三種方法設(shè)置參數(shù)
$template->setOptions(array('template_dir' => 'templates/default/')); //用于批量設(shè)置時使用
$template->set('template_dir', 'templates/default/');
$template->template_dir = 'templates/default/');
*/

$testArr = array('testa' => 'a', 'testb' => 'b');
include($template->getfile('test.htm'));
?>

相關(guān)文章

最新評論

望都县| 揭阳市| 大庆市| 英吉沙县| 临城县| 泰兴市| 涡阳县| 阿坝县| 汉中市| 达日县| 汾西县| 吉林市| 原平市| 巴林左旗| 通榆县| 邯郸县| 洛南县| 房产| 麦盖提县| 昌宁县| 蓝田县| 新龙县| 东平县| 阜平县| 米易县| 界首市| 安新县| 岳阳市| 安陆市| 库车县| 屯昌县| 呈贡县| 吴川市| 浑源县| 云梦县| 子洲县| 那坡县| 信丰县| 鄯善县| 泰来县| 铜川市|