手机
当前位置:查字典教程网 >编程开发 >php教程 >Discuz 模板引擎的封装类代码
Discuz 模板引擎的封装类代码
摘要:主要功能说明去掉了Discuz语言包的功能移植Discuz模板中所有的功能添加了自动更新缓存及生命周期功能在模板中的使用方法跟Discuz的...

主要功能说明

去掉了Discuz语言包的功能

移植Discuz模板中所有的功能

添加了自动更新缓存及生命周期功能

在模板中的使用方法跟Discuz的一样,所以就不做多余的说明了,使用前只需要做些简单的设置就可以了

如果需要使用discuz的语言包功能,只要去掉template.class.php第172行注释,并在template.func.php中加上discuz原来的languagevar函数就可以了

点击下载源文件

以下是代码范例:

/**

*使用示例

*

*@copyrightCopyright(c)2007-2008(http://www.tblog.com.cn)

*@authorAkon(番茄红了)

*@licensePHPVersion3.0{@linkhttp://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'));

?>

【Discuz 模板引擎的封装类代码】相关文章:

我的论坛源代码(十)

PHP5在Apache下的两种模式的安装

PHP设计模式之适配器模式代码实例

我的论坛源代码(八)

我的论坛源代码(二)

PHP设计模式之装饰者模式代码实例

我的论坛源代码(六)

一段php加密解密的代码

PHP.MVC的模板标签系统(三)

我的论坛源代码(七)

精品推荐
分类导航