找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1218|回复: 0

[分享] dede文章页面的上一篇下一篇增加文章摘要

[复制链接]
发表于 2018-2-28 10:20:45 | 显示全部楼层 |阅读模式 来自 中国–河南–新乡
系统默认的是在dede的上一篇和下一篇的链接只显示标题,但是有时我们希望显示其他信息,比如文章的摘要。

找到arc.archives.class.php文件,在include目录下面,然后查找“GetPreNext”这个函数,将

  1. $query
  2. = "Select
  3. arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,
  4. t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath
  5. from `jcode_archives` arc left join jcode_arctype t on arc.typeid=t.id ";
复制代码



改成

  1. $query = "Select
  2. arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,
  3. arc.description,t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath
  4. from `jcode_archives` arc left join jcode_arctype t on arc.typeid=t.id ";
复制代码



比较一下其实现在只是多了arc.description,这就是文章的摘要,也称为文章描述。
需要注意的是这里的jcode_archives和jcode_arctype中的jcode_是我表结构的前缀,你需要将这个前缀改成你自己的。

现在我们已经将文章描述从数据库里面取出来了。下一步将描述显示在页面上,显示连接文字的代码本来是这样的,你可以通过查找找到,其实就在上面那段代码的附近:

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']}\" />";
}
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']}\" />";
}
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中包含文章描述(红色部分):

  1. if(is_array($preRow))
  2. {
  3. $mlink =
  4. GetFileUrl($preRow['id'],$preRow['typeid'],$preRow['senddate'],$preRow['title'],$preRow['ismake'],$preRow['arcrank'],
  5. $preRow['namerule'],$preRow['typedir'],$preRow['money'],$preRow['filename'],$preRow['moresite'],$preRow['siteurl'],$preRow['sitepath']);
  6. $this->PreNext['pre']
  7. = "上一篇:<a href='$mlink'>{$preRow['title']}</a> [color=Red]<div>{$preRow['description']}</div>[/color]
  8. ";
  9. $this->PreNext['preimg'] = "<a href='$mlink'><img
  10. src="{$preRow['litpic']}" />}
  11. else
  12. {
  13. $this->PreNext['pre']
  14. = "上一篇:没有了 ";
  15. $this->PreNext['preimg'] ="<img
  16. src="/templets/default/images/nophoto.jpg"
  17. alt="对不起,没有上一图集了!"/>";
  18. }
  19. if(is_array($nextRow))
  20. {
  21. $mlink =
  22. GetFileUrl($nextRow['id'],$nextRow['typeid'],$nextRow['senddate'],$nextRow['title'],$nextRow['ismake'],$nextRow['arcrank'],
  23. $nextRow['namerule'],$nextRow['typedir'],$nextRow['money'],$nextRow['filename'],$nextRow['moresite'],$nextRow['siteurl'],$nextRow['sitepath']);
  24. $this->PreNext['next']
  25. = "下一篇:<a href='$mlink'>{$nextRow['title']}</a>[color=Red] <div>{$preRow['description']}</div>[/color]
  26. ";
  27. $this->PreNext['nextimg'] = "<a href='$mlink'><img
  28. src="{$nextRow['litpic']}" />}
  29. else
  30. {
  31. $this->PreNext['next']
  32. = "下一篇:没有了 ";
  33. $this->PreNext['nextimg'] ="<a href='javascript:void(0)'
  34. alt=""><img src="/templets/default/images/nophoto.jpg"
  35. alt="对不起,没有下一图集了!"/></a>";
  36. }
  37. }
复制代码

发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;

如何回报帮助你解决问题的坛友,好办法就是点击帖子下方的评分按钮给对方加【金币】不会扣除自己的积分,做一个热心并受欢迎的人!

▶专业解决各类DiscuzX疑难杂症、discuz版本升级 、网站搬家 和 云服务器销售!▶有偿服务QQ 860855665 更多精品应用
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则 需要先绑定手机号

关闭

站长推荐上一条 /1 下一条

QQ|侵权投诉|广告报价|手机版|小黑屋|西部数码代理|飘仙建站论坛 ( 豫ICP备2022021143号-1 )

GMT+8, 2025-2-2 16:35 , Processed in 0.042363 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表