您的位置:首页 > 编程语言 > PHP开发

ThinkPHP2.1 增加PHPCMS模板引擎,支持PC标签(get,json)

2011-11-15 13:44 323 查看
本人经常使用PHPCMS模板引擎。

用ThinkPHP2.1 自带的,感觉不爽,花点时间增加了个PHPCMS模板引擎

BY 夜色紫宸風

功能:PHPCMS模板解析引擎,支持PC标签(get,json),也可以使用ThinkPHP2.1的模板数据,都支持

TemplatePhpcms.class.php
把这个文件放到 ThinkPHP\Lib\Think\Util\Template 文件夹中

<?php
/**
+------------------------------------------------------------------------------
* TemplateLite模板引擎解析类
+------------------------------------------------------------------------------
* @category   Think
* @package  Think
* @subpackage  Util
* @author liu21st <liu21st@gmail.com>
* @version  $Id$
+------------------------------------------------------------------------------
*/
class TemplatePhpcms {
/**
+----------------------------------------------------------
* 渲染模板输出
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $templateFile 模板文件名
* @param array $var 模板变量
* @param string $charset 模板输出字符集
+----------------------------------------------------------
* @return void
+----------------------------------------------------------
*/
public function fetch($templateFile, $var, $charset) {

$templateFile = substr ( $templateFile, strlen ( TMPL_PATH ) );
$t=explode('/',$templateFile);
@extract($var);
include template($t[1],$t[2],$t[0]);
}
}
/**
* 模板调用
*
* @param $module
* @param $template
* @param $istag
* @return unknown_type
*/
function template($module = 'Index', $template = 'index', $style = 'default') {
$templateFile = $style.'/'.$module.'/'.$template;
vendor ( "TemplatePhpcms.class#phpcms" );

if (C ( 'TMPL_ENGINE_CONFIG' )) {
$config = C ( 'TMPL_ENGINE_CONFIG' );
} else {
$config = array ('template_dir' => TMPL_PATH, 'cache_dir' => CACHE_PATH, 'compile_dir' => TEMP_PATH );
}
$tpl = new Template_Phpcms ( $config );
$tpl->template_compile ( $templateFile );
return $config['cache_dir'].basename($template).'.php';
}
?>


class.phpcms.php
把这个文件放到 ThinkPHP\Vendor\TemplatePhpcms 文件夹中(TemplatePhpcms 这个目录要新建)
我倒。我汗。。贴上来,源码乱了。。。。
晕。压缩文件吧。。。
http://download.csdn.net/detail/wljk506/3798209
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息