實(shí)現(xiàn)讓DeDecms的上下文章鏈接限制在當(dāng)前欄目?jī)?nèi)
更新時(shí)間:2008年03月23日 18:27:15 作者:
使用dedecms的時(shí)候,當(dāng)打開(kāi)某篇文章的時(shí)候,底部會(huì)有“上一篇”“下一篇”的鏈接信息,默認(rèn)情況下,上下鏈接信息并沒(méi)有區(qū)分欄目的屬性,那么需要實(shí)現(xiàn)本欄目?jī)?nèi)的上下篇,如何實(shí)現(xiàn)呢?
基本思路:實(shí)現(xiàn)上下文章鏈接的函數(shù)位于GetPreNext(),我們?cè)谶@個(gè)函數(shù)中獲得欄目ID,然后修改SQL語(yǔ)句,在查詢(xún)數(shù)據(jù)庫(kù)的時(shí)候加上欄目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 .= "上一篇:沒(méi)有了 ";
}
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 .= " 下一篇:沒(méi)有了 ";
}
return $rs;
}
如果你不會(huì)修改,還可以下載修改后的: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 .= "上一篇:沒(méi)有了 ";
}
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 .= " 下一篇:沒(méi)有了 ";
}
return $rs;
}
如果你不會(huì)修改,還可以下載修改后的:inc_archives_view.php。
相關(guān)文章
為dedecms增加欄目文章統(tǒng)計(jì)功能代碼
有些網(wǎng)友希望為dedecms增加欄目文章統(tǒng)計(jì)的功能,這個(gè)功能并不復(fù)雜,但是dedecms本身并沒(méi)有此功能,以下是實(shí)現(xiàn)的方法:2008-03-03
DEDECMS TAG偽靜態(tài) IIS_rewrite配置方法附rewrite下載
使dedecms出現(xiàn)的偽靜態(tài)效果實(shí)現(xiàn)代碼2008-10-10
Dedecms 后臺(tái)驗(yàn)證碼錯(cuò)誤的解決方法
最近在本地搭建環(huán)境調(diào)試dedecms時(shí),發(fā)現(xiàn)安裝后后臺(tái)的驗(yàn)證碼無(wú)論如何都會(huì)提示輸入錯(cuò)誤,3.1有此情況,而3.01則不會(huì),上dede官方論壇和網(wǎng)上搜索都沒(méi)有找到解決的辦法,只能自己動(dòng)腦筋了~2009-03-03
dedecms織夢(mèng)模板引擎標(biāo)簽工作原理
織夢(mèng)模板引擎是一種使用XML名字空間形式的模板解析器,使用織夢(mèng)解析器解析模板的最大好處是可以輕松的制定標(biāo)記的屬性,感覺(jué)上就像在用HTML一樣,使模板代碼十分直觀靈活,新版的織夢(mèng)模板引擎不單能實(shí)現(xiàn)模板的解析還能分析模板里錯(cuò)誤的標(biāo)記。2022-12-12
DEDECMS后臺(tái)數(shù)據(jù)備份還原的應(yīng)用
前臺(tái)與測(cè)試過(guò)程--之備份與還原2009-02-02
dedecms tags keywords問(wèn)題修正方法
由于在經(jīng)常的使用過(guò)程中,我們添加信息一般都是不填寫(xiě)keywords的,我們只填寫(xiě)了tags,而這兩者我們一般情況下是一樣的。所以我給修改了下。2008-11-11

