微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

织梦CMS/Dedecms添加自定义函数

添加自定义函数文件:include/extend.func.PHP

实例:

//通过会员ID查看会员名称函数 

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

前台模板调用[field:mid function="GetMemberName(@me)"/]

//通过ID号获取类别的链接
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号获取文章链接
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;
}

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐