CTE

CTE(Cluries Templates Engine!) 更新到Version 2.0.0!

关于CTE:Cluries Templates Engine!一个PHP模板引擎,采用类似SMARTY的处理方式

欢迎大家把在使用中出现的BUG告诉我,可以通过EMAIL或者QQ或者在http://intgu.com/index.php/cte上留言

版本信息如下:

/**
* CTE: Cluries Templates Engine!
*
* @author : Cluries
* @link : http://www.intgu.com
* @version 2.0.0 dev 2009-06-14 (Require PHP version 5.0 or later)
*
* Usage Example I :
* require ‘CTE.php’;
* $tpl = new CTE();
* $tpl->setTemplatesDir(’templates\default’);
* $tpl->setCompileDir(’templates_c\default’);
* $tpl->setCacheDir(’_cache)’;
* $tpl->assign(’system’,array(name=>’Cluries Templates Engine WebHome!’,'keywords’=>’Cluries,Templates,Engine’));
* $tpl->display(’index.tpl’);
*
* 注意:在使用force-compile和developing模式下将不能使用缓存(可以开启缓存,但是不会使用)
* 在使用缓存时候debug功能无效
*
* Get More Information or Example Form: http://intgu.com/index.php/cte
* Amass bugs in:http://intgu.com/index.php/cte
* Update Url:http://intgu.com/index.php/cte
*
*/

说明:默认的templates目录为templates,compile目录为templates_c分别使用“<{”和“}>”作为左右边界符!默认模式下关闭了cache、force_compile、developing、debug,默认cache有效时间为5分钟

声明:CTE可修改,但是请保留原作者版权信息

注:下载链接在文章后面~请往下拉~~

最基本的使用例子:

PHPFILE:index.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
include 'CTE.php';
$tpl = new CTE();
$tpl->setCaching(0);
$tpl->setDebuging(1);
$tpl->setDebugLevel(9);
$tpl->setCacheLifeTime(5);
$tpl->setCompileDir('templates'); 
$tpl->assign('system',array(name=>'Cluries Templates Engine WebHome!','keywords'=>'Cluries,Templates,Engine','oh'=>'C中华人民共和国'));
$tpl->assign('root_path','this is the code of assign');
 
$sort_1 = array(array('title'=>"此分类文章_1",'url'=>"this_title_url"),array('title'=>"此分类文章_2",'url'=>"this_title_url"),array('title'=>"此分类文章_3",'url'=>"this_title_url"),array('title'=>"此分类文章_4",'url'=>"this_title_url"));
$sort_2 = array(array('title'=>"此分类文章_1",'url'=>"this_title_url"),array('title'=>"此分类文章_2",'url'=>"this_title_url"),array('title'=>"此分类文章_3",'url'=>"this_title_url"),array('title'=>"此分类文章_4",'url'=>"this_title_url"));
$sort_3 = array(array('title'=>"此分类文章_1",'url'=>"this_title_url"),array('title'=>"此分类文章_2",'url'=>"this_title_url"),array('title'=>"此分类文章_3",'url'=>"this_title_url"),array('title'=>"此分类文章_4",'url'=>"this_title_url"));
$articles = array(array('sort_name'=>'分类一','list'=>$sort_1),array('sort_name'=>'分类二','list'=>$sort_2),array('sort_name'=>'分类三','list'=>$sort_3));
 
$tpl->assign('article',$articles);
 
$tpl->display('index.tpl');
?>

TPLFILE:index.tpl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"  />
<meta http-equiv="keywords" content="<{$system.keywords}>" />
<title><{$system.name}></title>
<style type="text/css">
	body{background:#FFFFFF;color:#000000; font-family:"微软雅黑"; font-size:12px}
	a{ text-decoration:none; color:#000000}
	a:hover{text-decoration:underline}
	li{list-style:none;}
	ul{ margin:0; text-align:left}
	#section{width:300px; float:left; border:#cccccc 1px solid; margin-right:10px}
	.sec_tit{padding:3px 0 3px 5px; background:#cccccc; font-weight:bold; border-bottom:#00CCFF 1px solid}
	.sec_list{padding:5px}
 
</style>
</head>
<body>
<{include 'inc.tpl'}>
<{if $system.name==''}>
    本站无标题
<{else}>
    <{$system.name}>
<{/if}>
<{section name=sort loop=$article }>
<div id="section">
<div class="sec_tit"><{section[sort].sort_name}></div>
<div class="sec_list">
<ul>
<{section name=art loop=section[sort].list}>
		<li><a href="#<{section[art].url}>"><{if section[art].title!=''}><{section[art].title}><{else}>无标题<{/if}></a></li>	
<{/section}>
</ul>
</div>	
</div>
 
<{/section}>
</body>
</html>

下载CTE

SVN:http://cluries-cte.googlecode.com/svn/trunk/

Update: June 17th, 2009
  • Dec 13th, 2008 at 15:02 | #1

    CTE 什么东东?!

  • Dec 14th, 2008 at 01:51 | #2

    @Rui
    一个PHP的模板引擎~

  • Dec 15th, 2008 at 13:32 | #3

    NB!@Cluries

  • Jan 20th, 2009 at 16:13 | #4

    相较与smarty有什么特点或者优势么…发现初始化和smarty如出一辙…如果我做应用开发肯定也会优先考虑smarty了…

  • Jan 22nd, 2009 at 14:19 | #5

    @Rowe
    优势不敢说,毕竟人家做的东西都经历了那么多的考验,我这个唯一的优势可能就是体积没有那么臃肿吧?功能也没有Smarty那么多!至于始化和smarty如出一辙!本来就是为了兼容smarty的语法!因为当时写这个的时候用smarty用习惯了~

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
:p 8) :lol: =( :8 ;) :(( :o: :[ :) :D :-| :-[) :bloody: :cool: :choler: :love: :oups: :aie: :beurk: