代码如下:
//--------------------------
//获取上一篇,下一篇链接
//--------------------------
function GetPreNext($gtype='')
{
$rs = "";
if(count($this->PreNext)<2)
{</p> <p> $aid = $this->ArcID;
$idmax = $this->ArcID+10;
$idmin = $this->ArcID-10;
$next = " arc.ID>'$aid' And arc.arcrank>-1 And typeid='{$this->Fields['typeid']}' order by arc.ID asc ";
$pre = " arc.ID<'$aid' And arc.arcrank>-1 And typeid='{$this->Fields['typeid']}' order by arc.ID desc ";
$query = "Select arc.ID,arc.title,arc.shorttitle,
arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,
t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,
t.moresite,t.siteurl
from `{$this->MainTable}` arc left join dede_arctype t on arc.typeid=t.ID
where ";
$nextRow = $this->dsql->GetOne($query.$next);
$preRow = $this->dsql->GetOne($query.$pre);
if(is_array($preRow))
{
$mlink = GetFileUrl($preRow['ID'],$preRow['typeid'],$preRow['senddate'],$preRow['title'],$preRow['ismake'],$preRow['arcrank'],$preRow['namerule'],$preRow['typedir'],$preRow['money'],true,$preRow['siteurl']);
$this->PreNext['pre'] = "上一篇:<a href='$mlink' target='_blank'>{$preRow['title']}</a> ";
}
else{
$this->PreNext['pre'] = "上一篇:没有了 ";
}
if(is_array($nextRow))
{
$mlink = GetFileUrl($nextRow['ID'],$nextRow['typeid'],$nextRow['senddate'],$nextRow['title'],$nextRow['ismake'],$nextRow['arcrank'],$nextRow['namerule'],$nextRow['typedir'],$nextRow['money'],true,$nextRow['siteurl']);
$this->PreNext['next'] = "下一篇:<a href='$mlink' target='_blank'>{$nextRow['title']}</a> ";
}
else{
$this->PreNext['next'] = "下一篇:没有了 ";
}
}</p> <p> if($gtype=='pre'){
$rs = $this->PreNext['pre'];
}
else if($gtype=='next'){
$rs = $this->PreNext['next'];
}
else{
$rs = $this->PreNext['pre']." ".$this->PreNext['next'];
}</p> <p> return $rs;
}
改好的文件覆盖上传即可。
当然这里也是修改的sql语句
代码如下:
$next = " arc.ID>'$aid' And arc.arcrank>-1 And typeid='{$this->Fields['typeid']}' order by arc.ID asc ";
$pre = " arc.ID<'$aid' And arc.arcrank>-1 And typeid='{$this->Fields['typeid']}' order by arc.ID desc ";
因为可能版本不同,不建议直接全部复制,只需要替换下sql语句即可。要不容易出现错误。