主要功能說明
去掉了 Discuz 語言套件的功能
移植 Discuz 模板中所有的功能
添加了自動更新緩衝及生命週期功能
在模板中的使用方法跟Discuz的一樣,所以就不做多餘的說明了,使用前只需要做些簡單的設定就可以了
如果需要使用discuz的語言套件功能,只要去掉template.class.php第172行注釋,並在template.func.php中加上discuz原來的languagevar函數就可以了
點擊下載源檔案
以下是代碼範例:
/**
* 使用樣本
*
* @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, //當模板檔案有改動時重建緩衝 [關閉該項會快一些]
'cache_lifetime' => 1, //緩衝生命週期(分鐘),為 0 表示永久 [設定為 0 會快一些]
);
$template = Template::getInstance(); //使用單件模式執行個體化模板類
$template->setOptions($options); //設定模板參數
/*
// 可以使用以下三種方法設定參數
$template->setOptions(array('template_dir' => 'templates/default/')); //用於大量設定時使用
$template->set('template_dir', 'templates/default/');
$template->template_dir = 'templates/default/');
*/
$testArr = array('testa' => 'a', 'testb' => 'b');
include($template->getfile('test.htm'));
?>
http://www.bkjia.com/PHPjc/319202.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/319202.htmlTechArticle主要功能說明 去掉了Discuz語言套件的功能 移植Discuz模板中所有的功能 添加了自動更新緩衝及生命週期功能 在模板中的使用方法跟Discuz的一樣...