function GetOneArchive($aid)
{
global $dsql;
include_once(DEDEINC."/channelunit.func.php");
$aid = trim(ereg_replace('[^0-9]','',$aid));
$reArr = array();
$chRow = $dsql->GetOne("Select arc.*,ch.maintable,ch.addtable,ch.issystem
From `dede_arctiny` arc
left join `dede_channeltype` ch on ch.id=arc.channel where arc.id='$aid' ");
if(!is_array($chRow)) {
return $reArr;
}
else {
if(empty($chRow['maintable'])) $chRow['maintable'] = 'dede_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 `dede_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 `dede_arctype` tp on tp.id=arc.typeid
where arc.aid='$aid' ";
}
$arcRow = $dsql->GetOne($nquery);
if(!is_array($arcRow)) {
return $reArr;
}
if(!isset($arcRow['description'])) {
$arcRow['description'] = '';
}
if(empty($arcRow['description']) && isset($arcRow['body'])) {
$arcRow['description'] = cn_substr(html2text($arcRow['body']),250);
}
if(!isset($arcRow['pubdate'])) {
$arcRow['pubdate'] = $arcRow['senddate'];
}
if(!isset($arcRow['notpost'])) {
$arcRow['notpost'] = 0;
}
$reArr = $arcRow;
$reArr['aid'] = $aid;
$reArr['topid'] = $arcRow['topid'];
$reArr['arctitle'] = $arcRow['title'];
$reArr['arcurl'] = 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 $reArr;
}
|
这里,它处理$aid返回了一个$reArr数组,此数组有arcurl这个元素,这下很好理解sql标签中调用arcurl的方法了。
找到GetOneArchive函数,打开include文件夹下extend.func.php,加入以下代码:
function getOneArchiveElement($aid,$element='arcurl'){ $arcRow=GetOneArchive($aid); return $arcRow[$element]; } |
在模板文件datalist标记里调用如下标签:
{dede:field.aid function="GetOneArchiveElement(@me,'arcurl')"} |