Discuz模板引擎驱动无错版
浏览:7811
最后更新:2015-07-01 14:00
分类:驱动
下载把文件放到:
ThinkPHP\Library\Think\Template\Driver\Discuz.class.php
ThinkPHP\Library\Vendor\Discuz\template.class.php
修改配置文件
TMPL_ENGINE_TYPE = Discuz
TMPL_LINES_NEW = TRUE //去除html空格与换行
调用方式和thinkphp 官方一样
例子:
<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
$upda='外面';
$this->assign('upda', $upda);
$this->display('admin_setting');
}
}
使用方法:
加载头部模板标签
{template Public/header}
{subtemplate common/header}
条件判断
{if *} * {else} * {/if}
或 {if *} * {elseif *} * {else} * {/if}
或 {if *} * {/if}
其中{if *}中的*就是此判断语句的条件表达式,符合php的表达式。
例子:
{if !empty($c) || $a>10 && $b<10}
{$c}
{elseif $a>10}
{$a}
{else}
{$b}
{/if}foreach遍历{loop $a $b} * {/loop} 或者 {loop $a $b $c} * {/loop}
例子:
{loop $a $b $c}
第{$n}条:{$b}=>{$c}
{/loop}for循环{for $i=0;$i<10;$i++}*{/for}自增、自减例如自减 {$i--} {--$i} 自增 {$i++} {++$i}日期时间语法{date('Y-m-n',1402559168)}输出结果:2014-06-6语言语法
{lang _TEMPLATE_NOT_EXIST_} 输出结果:模板不存在
关于其他标签 的使用 请自行百度
