有人说: "要么旅行,要么读书,身体和灵魂,必须有一个在路上。 "这次川西之行我们走进四姑娘山。四姑娘山,是四座并立的山峰,山体陡峭,直指蓝天,冰雪覆盖,银光照人,享有 "蜀山皇后 "的美誉。
上次,余斗教大家《DedeCMS添加自定义函数function的方法》,今天余斗就给大家展示几个常用的自定义函数,大家可以在以后的做站过程中灵活使用,所有的代码均添加在自定义函数文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;
}
前台模板调用:
[field:mid function="GetTypeUrl(@me)"/]
//通过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;
}
前台模板调用:
[field:mid function="zGetArticleUrl(@me)"/]
到此这篇关于DedeCMS的几个自定义函数推荐就介绍到这了。你既然认准一条道路,何必去打听要走多久。更多相关DedeCMS的几个自定义函数推荐内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!