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

简介: 本人经常使用PHPCMS模板引擎。 用ThinkPHP2.1 自带的,感觉不爽,花点时间增加了个PHPCMS模板引擎 BY 夜色紫宸風 功能:PHPCMS模板解析引擎,支持PC标签(get,json),也可以使用ThinkPHP2.1的模板数据,都支持 TemplatePhpcms.class.php 把这个文件放到 ThinkPHP\Lib\Think\Util\Tem

本人经常使用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

目录
相关文章
|
JSON 数据格式
okhttp3 模拟get、post(json参数传递,form表单提交)
本文是博主学习okhttp3 的记录,希望对大家有所帮助。
1553 0
|
9月前
|
JSON PHP 数据格式
PHP中json传递请求字符串网址函数http_build_query()与parse_str(),将POST参数组转换拼接成GET请求链接
PHP中json传递请求字符串网址函数http_build_query()与parse_str(),将POST参数组转换拼接成GET请求链接
96 0
|
11月前
|
JSON 数据格式
txt2json(坐标点、标签txt文件转成labelme json标签文件)
txt2json(坐标点、标签txt文件转成labelme json标签文件)
272 0
|
JSON JavaScript 数据格式
js格式化json代码,以代码格式显示到页面,一个标签直接格式化
js格式化json代码,以代码格式显示到页面,一个标签直接格式化
1028 0
js格式化json代码,以代码格式显示到页面,一个标签直接格式化
|
JSON 数据格式 Spring
Ext-js 框架Bug(传回客户端的json对象被包在一对<pre>标签中)
 After 2 hours hard work ,I have solved the problem in the demo of permanent progress bar.         事实上,Ext-js的框架的BUG依然存在,这个BUG就是,当你用Spring框架的.
1160 0
|
JSON 数据格式 Shell
用ab进行POST,GET压力测试,且定义header及json的内容
这个以前没作过,找了文档。搞定。 要求时间的单curl测试的方式如下: time curl http://xxxxx/hq/restapi/isStart curl用来用post请求,且有header及请求内容 time curl -X POST -H "Content-Type...
6740 0
|
JSON Android开发 数据格式
Android中使用HttpURLConnection实现GET POST JSON数据与下载图片
Android中使用HttpURLConnection实现GET POST JSON数据与下载图片 Android6.0中把Apache HTTP Client所有的包与类都标记为deprecated不再建议使用 所有跟HTTP相关的数据请求与提交操作都通过HttpURLConnection类实...
1175 0