dedecms系統(tǒng)默認(rèn)的是在文章的上一篇和下一篇的鏈接只顯示標(biāo)題,但是有時我們希望顯示其他信息,比如文章的摘要。
找到arc.archives.class.php文件,在include目錄下面,然后查找“getprenext”這個函數(shù),將
$query
= select
arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,
t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath
from `jcode_archives` arc left join jcode_arctype t on arc.typeid=t.id ;
改成:
$query = select
arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,
arc.description,t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath
from `jcode_archives` arc left join jcode_arctype t on arc.typeid=t.id ;
比較一下其實(shí)現(xiàn)在只是多了arc.description,這就是文章的摘要,也稱為文章描述。
需要注意的是這里的jcode_archives和jcode_arctype中的jcode_是我表結(jié)構(gòu)的前綴,你需要將這個前綴改成你自己的。
現(xiàn)在我們已經(jīng)將文章描述從數(shù)據(jù)庫里面取出來了。下一步將描述顯示在頁面上,顯示連接文字的代碼本來是這樣的,你可以通過查找找到,其實(shí)就在上面那段代碼的附近:
if(is_array($prerow))
{
$mlink =
getfileurl($prerow['id'],$prerow['typeid'],$prerow['senddate'],$prerow['title'],$prerow['ismake'],$prerow['arcrank'],
$prerow['namerule'],$prerow['typedir'],$prerow['money'],$prerow['filename'],$prerow['moresite'],$prerow['siteurl'],$prerow['sitepath']);
$this->prenext['pre']
= 上一篇:<a href='$mlink'>{$prerow['title']}</a>
;
$this->prenext['preimg'] = <a href='$mlink'><img
src={$prerow['litpic']} alt={$prerow['title']}/></a>
;
}
else
{
$this->prenext['pre'] = 上一篇:沒有了 ;
$this->prenext['preimg']
=<img src=/templets/default/images/nophoto.jpg
alt=對不起,沒有上一圖集了!/>;
}
if(is_array($nextrow))
{
$mlink =
getfileurl($nextrow['id'],$nextrow['typeid'],$nextrow['senddate'],$nextrow['title'],$nextrow['ismake'],$nextrow['arcrank'],
$nextrow['namerule'],$nextrow['typedir'],$nextrow['money'],$nextrow['filename'],$nextrow['moresite'],$nextrow['siteurl'],$nextrow['sitepath']);
$this->prenext['next']
= 下一篇:<a href='$mlink'>{$nextrow['title']}</a>
;
$this->prenext['nextimg'] = <a href='$mlink'><img
src={$nextrow['litpic']} alt={$nextrow['title']}/></a>
;
}
else
{
$this->prenext['next'] = 下一篇:沒有了 ;
$this->prenext['nextimg'] =<a href='javascript:void(0)'
alt=><img src=/templets/default/images/nophoto.jpg
alt=對不起,沒有下一圖集了!/></a>;
}
}
現(xiàn)在為了顯示出文章描述,在每一個a標(biāo)簽之后添加一個div div中包含文章描述:
if(is_array($prerow))
{
$mlink =
getfileurl($prerow['id'],$prerow['typeid'],$prerow['senddate'],$prerow['title'],$prerow['ismake'],$prerow['arcrank'],
$prerow['namerule'],$prerow['typedir'],$prerow['money'],$prerow['filename'],$prerow['moresite'],$prerow['siteurl'],$prerow['sitepath']);
$this->prenext['pre']
= 上一篇:<a href='$mlink'>{$prerow['title']}</a> <div>{$prerow['description']}</div>
;
$this->prenext['preimg'] = <a href='$mlink'><img
src={$prerow['litpic']} alt={$prerow['title']}/></a> <div>{$prerow['description']}</div> ;
}
else
{
$this->prenext['pre']
= 上一篇:沒有了 ;
$this->prenext['preimg'] =<img
src=/templets/default/images/nophoto.jpg
alt=對不起,沒有上一圖集了!/>;
}
if(is_array($nextrow))
{
$mlink =
getfileurl($nextrow['id'],$nextrow['typeid'],$nextrow['senddate'],$nextrow['title'],$nextrow['ismake'],$nextrow['arcrank'],
$nextrow['namerule'],$nextrow['typedir'],$nextrow['money'],$nextrow['filename'],$nextrow['moresite'],$nextrow['siteurl'],$nextrow['sitepath']);
$this->prenext['next']
= 下一篇:<a href='$mlink'>{$nextrow['title']}</a> <div>{$prerow['description']}</div>
;
$this->prenext['nextimg'] = <a href='$mlink'><img
src={$nextrow['litpic']} alt={$nextrow['title']}/></a> <div>{$prerow['description']}</div> ;
}
else
{
$this->prenext['next']
= 下一篇:沒有了 ;
$this->prenext['nextimg'] =<a href='javascript:void(0)'
alt=><img src=/templets/default/images/nophoto.jpg
alt=對不起,沒有下一圖集了!/></a>;
}
}
這樣做的話能顯示文章摘要,但是格式可能會很亂,你可以根據(jù)需要增加樣式。