Discuz模板引擎驅動無錯版
本文關鍵詞:discuz模板
更多相關文章: 擴展 thinkphp擴展 發(fā)布擴展 個性二維碼生成類 微信公眾平臺SDK ueditor編輯器 pjax分頁操作
discuz模板引擎,,先前有人發(fā)布了一個發(fā)現(xiàn)問題很多,自己就手動也弄了個,希望大家喜歡,有問題反饋給我...所有標簽都是按照Discuz 來的,語言標簽在這里一樣有效..
下載把文件放到:
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循環(huán){for $i=0;$i<10;$i++}*{/for}自增、自減例如自減 {$i--} {--$i} 自增 {$i++} {++$i}日期時間語法{date('Y-m-n',1402559168)}輸出結果:2014-06-6
語言語法{lang _TEMPLATE_NOT_EXIST_}
輸出結果:模板不存在
關于其他標簽 的使用 請自行百度
本文編號:1340826
本文鏈接:http://www.sikaile.net/wenshubaike/mfmb/1340826.html