主頁 > 網(wǎng)站建設(shè) > 建站知識(shí) > 織夢(mèng)CMS/Dedecms添加自定義函數(shù)

織夢(mèng)CMS/Dedecms添加自定義函數(shù)

POST TIME:2017-11-12 23:42

添加自定義函數(shù)文件:include/extend.func.php

實(shí)例:

//通過會(huì)員ID查看會(huì)員名稱的函數(shù)

function GetMemberName($str){
$dsql = new Dedesql(false);
$row = $dsql->GetOne("SELECT uname FROM `ddmx_member` WHERE mid = '$str' ");
return $row[uname];
}

前臺(tái)模板調(diào)用[field:mid function="GetMemberName(@me)"/]

//通過ID號(hào)獲取類別的鏈接
function GetTypeUrl($tid)
{
global $dsql;
global $cfg_cmspath;

$query ="select typedir from ‘#` where ;

if($row=$dsql->getone($query))
{
$temp=str_replace("{cmspath}",$cfg_cmspath,$row['typedir']).'/';
}
return $temp;
}

//通過ID號(hào)獲取文章的鏈接
function zGetArticleUrl($id)
{
global $dsql;
global $cfg_cmspath;
$query ="select id,typedir,namerule from ‘#` where typeid from ‘#` where ;
if($row = $dsql->getone($query))
{
$arc=$row['namerule'];
$type=str_replace("{cmspath}",$cfg_cmspath,$row['typedir']);
$temp=str_replace("{typedir}",$type,$temp);
$temp=str_replace("{aid}",$id,$temp);
}
return $temp;
}




上一篇:dede織夢(mèng)cms系統(tǒng)中如何添加自定義標(biāo)簽方法functi

下一篇:織夢(mèng)欄目字段添加并調(diào)用:例如圖片上傳

收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266