找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1402|回复: 0

[分享] dedecms5.7上一篇下一篇分开调用教程

[复制链接]
发表于 2018-6-30 10:10:00 | 显示全部楼层 |阅读模式 来自 中国–河南–新乡
功能:
1.文章内容页面上一篇、下一篇分两个标签调用,模板制作更方便!
2.调用的上一篇、下一篇文章改为本文章所在栏目,而不是现在的全站。
调用例子:
  1. <div style="text-align: left">↑{dede:preurl/}</div>
  2. <div style="text-align: left">↓{dede:nexturl/}</div>
复制代码

改法:打开includeinc_archives_view.php
找到
  1. //--------------------------
  2. //获取上一篇,下一篇链接
  3. //--------------------------
  4. function GetPreNext()
  5. {
  6. $rs = "";
  7. $aid = $this->ArcID;
  8. $next = " dede_archives.ID>'$aid' order by dede_archives.ID asc ";
  9. $pre = " dede_archives.ID<'$aid' order by dede_archives.ID desc ";
  10. $query = "Select dede_archives.ID,dede_archives.title,
  11. dede_archives.typeid,dede_archives.ismake,dede_archives.senddate,dede_archives.arcrank,dede_archives.money,
  12. dede_arctype.typedir,dede_arctype.typename,dede_arctype.namerule,dede_arctype.namerule2,dede_arctype.ispart,
  13. dede_arctype.moresite,dede_arctype.siteurl
  14. from dede_archives left join dede_arctype on dede_archives.typeid=dede_arctype.ID
  15. where ";
  16. $nextRow = $this->dsql->GetOne($query.$next);
  17. $preRow = $this->dsql->GetOne($query.$pre);
  18. if(is_array($preRow)){
  19. $mlink = GetFileUrl($preRow['ID'],$preRow['typeid'],$preRow['senddate'],$preRow['title'],$preRow['ismake'],$preRow['arcrank'],$preRow['namerule'],$preRow['typedir'],$preRow['money'],true,$preRow['siteurl']);
  20. $rs .= "上一篇:<a href='$mlink'>{$preRow['title']}</a> ";
  21. }
  22. else{
  23. $rs .= "上一篇:没有了 ";
  24. }
  25. if(is_array($nextRow)){
  26. $mlink = GetFileUrl($nextRow['ID'],$nextRow['typeid'],$nextRow['senddate'],$nextRow['title'],$nextRow['ismake'],$nextRow['arcrank'],$nextRow['namerule'],$nextRow['typedir'],$nextRow['money'],true,$nextRow['siteurl']);
  27. $rs .= " 下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
  28. }
  29. else{
  30. $rs .= " 下一篇:没有了 ";
  31. }
  32. return $rs;
  33. }
复制代码

改为:
  1. //--------------------------
  2. //获取上一篇,下一篇链接
  3. //--------------------------
  4. function GetPreNext($pn=1)
  5. {
  6. $rs = "";
  7. $aid = $this->ArcID;
  8. $typeid = $this->Fields['typeid'];
  9. $next = " dede_archives.ID>'$aid' and dede_archives.typeid='$typeid' order by dede_archives.ID asc ";
  10. $pre = " dede_archives.ID<'$aid' and dede_archives.typeid='$typeid' order by dede_archives.ID desc ";
  11. $query = "Select dede_archives.ID,dede_archives.title,
  12. dede_archives.typeid,dede_archives.ismake,dede_archives.senddate,dede_archives.arcrank,dede_archives.money,
  13. dede_arctype.typedir,dede_arctype.typename,dede_arctype.namerule,dede_arctype.namerule2,dede_arctype.ispart,dede_arctype.moresite,dede_arctype.siteurl
  14. from dede_archives left join dede_arctype on dede_archives.typeid=dede_arctype.ID
  15. where ";
  16. if($pn == 0){
  17. $preRow = $this->dsql->GetOne($query.$pre);
  18. if(is_array($preRow)){
  19. $mlink = GetFileUrl($preRow['ID'],$preRow['typeid'],$preRow['senddate'],$preRow['title'],$preRow['ismake'],$preRow['arcrank'],$preRow['namerule'],$preRow['typedir'],$preRow['money'],true,$preRow['siteurl']);
  20. $prs .= "上一篇:<a href='$mlink'>{$preRow['title']}</a> ";
  21. }
  22. else{
  23. $prs .= "上一篇:没有了 ";
  24. }
  25. return $prs;
  26. }
  27. else{
  28. $nextRow = $this->dsql->GetOne($query.$next);
  29. if(is_array($nextRow)){
  30. $mlink = GetFileUrl($nextRow['ID'],$nextRow['typeid'],$nextRow['senddate'],$nextRow['title'],$nextRow['ismake'],$nextRow['arcrank'],$nextRow['namerule'],$nextRow['typedir'],$nextRow['money'],true,$nextRow['siteurl']);
  31. $nrs .= "下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
  32. }
  33. else{
  34. $nrs .= "下一篇:没有了 ";
  35. }
  36. return $nrs;
  37. }
  38. }
复制代码

找到:
  1. //上下篇链接
  2. else if($tagname=="prenext"){
  3. $this->dtp->Assign($tagid,$this->GetPreNext());
  4. }
复制代码

改为:
  1. //上下篇链接
  2. else if($tagname=="preurl"){
  3. $this->dtp->Assign($tagid,$this->GetPreNext(0));
  4. }
  5. else if($tagname=="nexturl"){
  6. $this->dtp->Assign($tagid,$this->GetPreNext());
  7. }
复制代码


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

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

您需要登录后才可以回帖 登录 | 立即注册

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

关闭

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

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

GMT+8, 2024-11-26 16:34 , Processed in 0.036386 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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