POST TIME:2019-03-19 17:12
{dede:field.tong_gg php=yes}
if(@me==””||empty(@me)) 版權所有
@me=”<p>無</p>”;
{/dede:field.tong_gg}
注釋:
@me:就是當前字段的值,你可以在if中給其賦值,然后判斷結束后它的值就變成你賦的值,打印出來
下面來說說具體的方法:
方法一:
用個if判斷語句,判斷一個字段是否有東西,有就輸出1,沒有則就出2,
下面是的代碼加載內容頁模板中
{dede:field.audio runphp=’yes’}
if(@me<>”)@me=”如果audio字段里有東西就輸出這個,支持html代碼,并且可以在代碼中使用@me來調用audio字
段值,但是不要有雙引號。”;
else
@me=”如果audio字段里沒有東西就輸出這個,也是支持html代碼,并且也是可以在代碼中使用@me來調用audio字
段值,也是不要有雙引號。”;
{/dede:field.audio}
audio是自己添加的一個字段
方法二:
給DEDE模板加了新功能 if判斷功能 標簽iif和elserun
增加了變量$str和$str_count $str是最終顯示的內容 $str_count是循環顯示內容的條數。
增加了標簽iif 和 elserun 滿足iif的條件就正常運行 如果不滿iif的條件就運行elserun
如果不滿足iif的條件,也沒指定elserun就返回空白
iif和elserun都是正常的php語法.
{dede:arclist orderby=’click’ titlelen=’30′ row=’10′ iif=”$str_count>1″ elserun=”$str=暫時沒有內
容”}
<li><span>[field:textlink/]</span></li>
{/dede:arclist}
運行結果 如果arclist沒返回結果就顯示 暫時沒內容
<title>{dede:global name=’cfg_webname’ iif=”strlen($str)>10″ elserun=”$str.=’我的網站’”/} </title>
運行結果 如果cfg_webname長度大于10就正常顯示
否則就在標題后面增加我的網站
顯示
更改方法 只更改一個文件就是/dede/include/pub_dedetag.php
一、搜索
foreach($GLOBALS[$arr] as $k=>$v){
更改成
$GLOBALS['autoindex']=0;
foreach($GLOBALS[$arr] as $k=>$v){
$GLOBALS['autoindex']++;
二、搜索
$this->CTags[$i]->TagValue = $DedeMeValue;
}
在后面加上
$str = $this->CTags[$i]->TagValue;
$str_count = $GLOBALS['autoindex'];
if( $this->CTags[$i]->GetAtt(“iif”)!=”” ){
if(! eval(“return {$this->CTags[$i]->GetAtt(‘iif’)} ;” )){
if($this->CTags[$i]->GetAtt(“elserun”)) {
$this->CTags[$i]->TagValue=eval(“return {$this->CTags[$i]->GetAtt(‘elserun’)} ;” );
}else{
$this->CTags[$i]->TagValue=”;
/*本文由織夢者(www.genban.org)轉自網絡*/
}
}
}