如果我們想用一個自定義的織夢標(biāo)簽調(diào)用內(nèi)容(例如:{dede:dedecms91084 name='hello'/})顯然這個標(biāo)簽不是織夢默認(rèn)的,如果我們想要用它來調(diào)用數(shù)據(jù),用以下方法可以實(shí)現(xiàn)。
新建一個php文件,命名為dedecm91084.lib.php,把php文件放到/include/taglib/文件夾下
<?php
if (!defined('DEDEINC')) exit("Request Error!");
function lib_dedecms91084(&$ctag, &$refObj)
{
    global $dsql, $envs;
    //屬性處理
    $attlist = "name|";
    FillAttsDefault($ctag->CAttribute->Items, $attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);
    $revalue = $name();
    return $revalue;
}
function hello()
{
    $html = "格展網(wǎng)絡(luò)";
    return $html;
}
?>
在模板中可以用{dede:dedecms91084 name='hello'/}來調(diào)用,輸出內(nèi)容為“你好”
  • 詳解
{dede:dedecms91084 name='hello'/}中的dedecms91084是php文件名dedecms91084.lib.php的前半部分,name='hello'中的hello和第13行的function hello()對應(yīng)。
注意,php第三行的function lib_dedecms91084(&$ctag, &$refObj)中的dedecms91084要和標(biāo)簽一致才可以哦。