婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 網站建設 > 建站知識 > Dedecms上一篇下一篇增加文章摘要的功能

Dedecms上一篇下一篇增加文章摘要的功能

POST TIME:2018-01-16 19:59

系統默認的是在dede的上一篇和下一篇的鏈接只顯示標題,但是有時我們希望顯示其他信息,比如文章的摘要。
找到arc.archives.class.php文件,在include目錄下面,然后查找“GetPreNext”這個函數,將

$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 `xxy5.com_archives` arc left join xxy5.com_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 `xxy5.com_archives` arc left join xxy5.com_arctype t on arc.typeid=t.id “;

比較一下其實現在只是多了arc.description,這就是文章的摘要,也稱為文章描述。
需要注意的是這里的xxy5.com_archives和xxy5.com_arctype中的xxy5.com_是表結構的前綴,你需要將這個前綴改成你自己的。

現在我們已經將文章描述從數據庫里面取出來了。下一步將描述顯示在頁面上,顯示連接文字的代碼本來是這樣的,你可以通過查找找到,其實就在上面那段代碼的附近:

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>”;
}
}

現在為了顯示出文章描述,在每一個a標簽之后添加一個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>”;
}
}

這樣做的話能顯示文章摘要,但是格式可能會很亂,你可以根據需要增加樣式。



收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266
主站蜘蛛池模板: 隆化县| 伊吾县| 洛川县| 黄陵县| 汶川县| 陵水| 衡南县| 伽师县| 湛江市| 垫江县| 和硕县| 赞皇县| 出国| 永丰县| 普洱| 枣强县| 巫山县| 宁晋县| 呼伦贝尔市| 怀安县| 西乌| 江川县| 铜川市| 隆子县| 玉门市| 烟台市| 辽中县| 淮北市| 大同市| 个旧市| 成安县| 水富县| 天津市| 汝阳县| 同德县| 高清| 福贡县| 桐乡市| 泰顺县| 罗平县| 民勤县|