dedecms 自定义用到的函数
为了不与已存在的函数相冲突,自定义函数前面加小写的'z'
//通过ID号获取类别的链接
function zGetTypeUrl($tid)
{
global $dsql;
global $cfg_cmspath;
$query ="select typedir from ‘#@__arctype` where id=$tid";
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 ‘#@__arctype` where id=(select typeid from ‘#@__archives` where id = $id)";
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;
}