實現(xiàn)讓DeDecms的上下文章鏈接限制在當(dāng)前欄目內(nèi)
更新時間:2008年03月23日 18:27:15 作者:
使用dedecms的時候,當(dāng)打開某篇文章的時候,底部會有“上一篇”“下一篇”的鏈接信息,默認(rèn)情況下,上下鏈接信息并沒有區(qū)分欄目的屬性,那么需要實現(xiàn)本欄目內(nèi)的上下篇,如何實現(xiàn)呢?
基本思路:實現(xiàn)上下文章鏈接的函數(shù)位于GetPreNext(),我們在這個函數(shù)中獲得欄目ID,然后修改SQL語句,在查詢數(shù)據(jù)庫的時候加上欄目ID的限制。
修改方法:
找到include/inc_archives_view.php中的function GetPreNext()函數(shù),修改為:
//--------------------------
//獲取上一篇,下一篇鏈接
//--------------------------
function GetPreNext()
{
$rs = "";
$aid = $this->ArcID;
$rid = $this->Fields['typeid'];
$next = " #@__archives.ID>'$aid' and #@__archives.typeID='$rid' order by #@__archives.ID asc ";
$pre = " #@__archives.ID<'$aid' and #@__archives.typeID='$rid' order by #@__archives.ID desc ";
//$next = " #@__archives.ID>'$aid' order by #@__archives.ID asc ";
//$pre = " #@__archives.ID<'$aid' order by #@__archives.ID desc ";
$query = "Select #@__archives.ID,#@__archives.title,
#@__archives.typeid,#@__archives.ismake,#@__archives.senddate,#@__archives.arcrank,#@__archives.money,
#@__arctype.typedir,#@__arctype.typename,#@__arctype.namerule,#@__arctype.namerule2,#@__arctype.ispart,
#@__arctype.moresite,#@__arctype.siteurl
from #@__archives left join #@__arctype on #@__archives.typeid=#@__arctype.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']);
$rs .= "上一篇:<a href='$mlink'>{$preRow['title']}</a> ";
}
else{
$rs .= "上一篇:沒有了 ";
}
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']);
$rs .= " 下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
}
else{
$rs .= " 下一篇:沒有了 ";
}
return $rs;
}
如果你不會修改,還可以下載修改后的:inc_archives_view.php。
找到include/inc_archives_view.php中的function GetPreNext()函數(shù),修改為:
復(fù)制代碼 代碼如下:
//--------------------------
//獲取上一篇,下一篇鏈接
//--------------------------
function GetPreNext()
{
$rs = "";
$aid = $this->ArcID;
$rid = $this->Fields['typeid'];
$next = " #@__archives.ID>'$aid' and #@__archives.typeID='$rid' order by #@__archives.ID asc ";
$pre = " #@__archives.ID<'$aid' and #@__archives.typeID='$rid' order by #@__archives.ID desc ";
//$next = " #@__archives.ID>'$aid' order by #@__archives.ID asc ";
//$pre = " #@__archives.ID<'$aid' order by #@__archives.ID desc ";
$query = "Select #@__archives.ID,#@__archives.title,
#@__archives.typeid,#@__archives.ismake,#@__archives.senddate,#@__archives.arcrank,#@__archives.money,
#@__arctype.typedir,#@__arctype.typename,#@__arctype.namerule,#@__arctype.namerule2,#@__arctype.ispart,
#@__arctype.moresite,#@__arctype.siteurl
from #@__archives left join #@__arctype on #@__archives.typeid=#@__arctype.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']);
$rs .= "上一篇:<a href='$mlink'>{$preRow['title']}</a> ";
}
else{
$rs .= "上一篇:沒有了 ";
}
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']);
$rs .= " 下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
}
else{
$rs .= " 下一篇:沒有了 ";
}
return $rs;
}
如果你不會修改,還可以下載修改后的:inc_archives_view.php。
相關(guān)文章
DEDECMS TAG偽靜態(tài) IIS_rewrite配置方法附rewrite下載
使dedecms出現(xiàn)的偽靜態(tài)效果實現(xiàn)代碼2008-10-10
DEDECMS后臺數(shù)據(jù)備份還原的應(yīng)用
前臺與測試過程--之備份與還原2009-02-02

