溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

織夢(mèng)DEDECMS擴(kuò)展標(biāo)簽的使用方法

發(fā)布時(shí)間:2020-08-18 13:49:00 來源:億速云 閱讀:135 作者:小新 欄目:建站服務(wù)器

這篇文章主要介紹織夢(mèng)DEDECMS擴(kuò)展標(biāo)簽的使用方法,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

織夢(mèng)DEDECMS擴(kuò)展標(biāo)簽怎么用?

織夢(mèng)DEDECMS擴(kuò)展標(biāo)簽演示實(shí)例

推薦學(xué)習(xí):織夢(mèng)cms

我們可以看一個(gè)示例標(biāo)簽:demotag.lib.php ,

if(!defined('DEDEINC')) 
{ 
exit("Request Error!"); 
} 
function lib_demotag(&$ctag,&$refObj) 
{ 
global $dsql,$envs; 
 
$attlist="row|12,titlelen|24"; 
FillAttsDefault($ctag->CAttribute->Items,$attlist); 
extract($ctag->CAttribute->Items, EXTR_SKIP); 
$revalue = ''; 
 
//------------------------------------------------------ 
$revalue = 'Hello Word!'; 
//------------------------------------------------------ 
return $revalue; 
} 
?>

我們會(huì)發(fā)現(xiàn)標(biāo)簽起作用了,輸出了我們的內(nèi)容。

織夢(mèng)DEDECMS擴(kuò)展標(biāo)簽的使用方法

$revalue = 'Hello Word!'; 
$revalue .=" 
Row:".$row.";TitleLen:".$titlelen;

織夢(mèng)DEDECMS擴(kuò)展標(biāo)簽的使用方法

這樣我們可以看到,這個(gè)屬性已經(jīng)被創(chuàng)建變量并且賦值了。

接下來我們可以再進(jìn)一步去修改這個(gè)標(biāo)簽。

function lib_writerarc(&$ctag,&$refObj)

接下來我們就可以編寫查詢語(yǔ)句及對(duì)底層模板處理的相關(guān)函數(shù)了

$revalue = ''; 
$innertext = $ctag->GetInnerText(); 
$ctp = new DedeTagParse(); 
$ctp->SetNameSpace('field', '[', ']'); 
$sql = "SELECT * FROM dede_archives WHERE writer='{$refObj->Fields['writer']}' limit 0, $row"; 
 
 
 
$dsql->Execute('me',$sql); 
while($rs = $dsql->GetArray('me')) 
{ 
 
$rs['title'] = cn_substr($rs['title'], $titlelen); 
 
$ctp->LoadSource($innertext); 
foreach($ctp->CTags as $tagid=>$ctag) { 
if(!emptyempty($rs[strtolower($ctag->GetName())])) { 
$ctp->Assign($tagid,$rs[$ctag->GetName()]); 
} 
} 
 
$revalue .= $ctp->GetResult(); 
}

最后返回這個(gè)值return $revalue;

整個(gè)文件內(nèi)容如下:

if(!defined('DEDEINC')) 
{ 
exit("Request Error!"); 
} 
function lib_writerarc(&$ctag,&$refObj) 
{ 
global $dsql,$envs; 
 
$attlist="row|12,titlelen|24"; 
FillAttsDefault($ctag->CAttribute->Items,$attlist); 
extract($ctag->CAttribute->Items, EXTR_SKIP); 
$revalue = ''; 
$innertext = $ctag->GetInnerText(); 
$ctp = new DedeTagParse(); 
$ctp->SetNameSpace('field', '[', ']'); 
$sql = "SELECT * FROM dede_archives WHERE writer='{$refObj->Fields['writer']}' limit 0, $row"; 
$dsql->Execute('me',$sql); 
while($rs = $dsql->GetArray('me')) 
{ 
 
$rs['title'] = cn_substr($rs['title'], $titlelen); 
 
$ctp->LoadSource($innertext); 
foreach($ctp->CTags as $tagid=>$ctag) { 
if(!emptyempty($rs[strtolower($ctag->GetName())])) { 
$ctp->Assign($tagid,$rs[$ctag->GetName()]); 
} 
} 
 
$revalue .= $ctp->GetResult(); 
} 
return $revalue; 
} 
?>

通過動(dòng)態(tài)瀏覽頁(yè)面進(jìn)行查看調(diào)試?aid=3

{dede:writerarc row='10' titlelen='6'} 
[field:title/]  
{/dede:writerarc}

織夢(mèng)DEDECMS擴(kuò)展標(biāo)簽的使用方法

以上是織夢(mèng)DEDECMS擴(kuò)展標(biāo)簽的使用方法的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI