欢迎来到元素模板WWW.YS720.COM,本站提供专业的织梦模板网站模板ASPCMS模板
当前位置:主页 > 程序教程 > DEDECMS教程 >
DEDECMS教程

织梦dede根据文章ID获取文章静态地址的函数

(元素模板) / 2019-04-08 10:07
凡是用到公用表的任何模型都可以使用~

增加到 inculde\extend.func.php 文件最后的?>之前(如果没有这个文件,请新建一个,并在以下代码前后分别加上 <?   和  ?>)

 function GetOneDocUrl($aid)
{
     global $dsql;
     include_once(DEDEINC."/channelunit.func.php");
     $aid = trim(ereg_replace('[^0-9]','',$aid));

     $chRow = $dsql->GetOne("Select arc.*,ch.maintable,ch.addtable,ch.issystem From `2d30_arctiny` arc left join `2d30_channeltype` ch on ch.id=arc.channel where arc.id='$aid' ");

     if(!is_array($chRow)) {
         return $reArr;
     }
     else {
         if(empty($chRow['maintable'])) $chRow['maintable'] = '2d30_archives';
     }

     if($chRow['issystem']!=-1)
     {
         $nquery = " Select arc.*,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath
                     From `{$chRow['maintable']}` arc left join `2d30_arctype` tp on tp.id=arc.typeid
                    where arc.id='$aid' ";
     }
     else
     {
         $nquery = " Select arc.*,1 as ismake,0 as money,'' as filename,tp.typedir,tp.topid,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath
                     From `{$chRow['addtable']}` arc left join `2d30_arctype` tp on tp.id=arc.typeid
                     where arc.aid='$aid' ";
     }

     $arcRow = $dsql->GetOne($nquery);

     $Url = GetFileUrl($aid,$arcRow['typeid'],$arcRow['senddate'],$reArr['title'],$arcRow['ismake'],$arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],$arcRow['filename'],$arcRow['moresite'],$arcRow['siteurl'],$arcRow['sitepath']);
     return $Url;
 }


在自己写的PHP标签或SQL标签里调用方式为 [dede:field.id function='GetOneDocUrl(@me)'/]
Copyright @ 2013-2019 元素模板 YS720.COM All Rights Reserved. 版权所有 元素模板 YS720.COM