DedeCMS织梦

DedeCMS织梦单独调用上下篇文章链接和标题

也想出现在这里?联系我们
创客云

织梦默认的上一篇,下一篇调用标签是:{dede:prenext get='pre'/} {dede:prenext get='next'/},有的情况加 我们只想要单独的链接和标题那该怎么办呢!接下来交大家方法.

第一步:

打开/include/arc.archives.class.php 文件找到:

也想出现在这里?联系我们
创客主机
  1. /**
  2.      *  获取上一篇,下一篇链接
  3.      *
  4.      * @access    public
  5.      * @param     string  $gtype  获取类型  
  6.      *                    pre:上一篇  preimg:上一篇图片  next:下一篇  nextimg:下一篇图片
  7.      * @return    string
  8.      */

  大概在 795 行左右
1-1606031A335440
替换代码如下:

  1. /**
  2.      *  获取上一篇,下一篇链接
  3.      *
  4.      * @access    public
  5.      * @param     string  $gtype  获取类型  
  6.      *                    pre:上一篇  preimg:上一篇图片  next:下一篇  nextimg:下一篇图片
  7.      * @return    string
  8.      */
  9.     function GetPreNext($gtype='')
  10.     {
  11.         $rs = '';
  12.         if(count($this->PreNext)<2)
  13.         {
  14.             $aid = $this->ArcID;
  15.             $preR =  $this->dsql->GetOne("Select id From `dede_arctiny` where id<$aid And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id desc");
  16.             $nextR = $this->dsql->GetOne("Select id From `dede_arctiny` where id>$aid And arcrank>-1 And typeid='{$this->Fields['typeid']}' order by id asc");
  17.             $next = (is_array($nextR) ? " where arc.id={$nextR['id']} " : ' where 1>2 ');
  18.             $pre = (is_array($preR) ? " where arc.id={$preR['id']} " : ' where 1>2 ');
  19.             $query = "Select arc.id,arc.title,arc.shorttitle,arc.typeid,arc.ismake,arc.senddate,arc.arcrank,arc.money,arc.filename,arc.litpic,
  20.                         t.typedir,t.typename,t.namerule,t.namerule2,t.ispart,t.moresite,t.siteurl,t.sitepath
  21.                         from `dede_archives` arc left join dede_arctype t on arc.typeid=t.id  ";
  22.             $nextRow = $this->dsql->GetOne($query.$next);
  23.             $preRow = $this->dsql->GetOne($query.$pre);
  24.             if(is_array($preRow))
  25.             {
  26.                 $mlink = GetFileUrl($preRow['id'],$preRow['typeid'],$preRow['senddate'],$preRow['title'],$preRow['ismake'],$preRow['arcrank'],
  27.                 $preRow['namerule'],$preRow['typedir'],$preRow['money'],$preRow['filename'],$preRow['moresite'],$preRow['siteurl'],$preRow['sitepath']);
  28.                 $this->PreNext['next'] = "上一篇:<a href='$mlink'>{$preRow['title']}</a> ";
  29. $this->PreNext['nexturl'] = "$mlink"; //上一篇链接地址
  30. $this->PreNext['nextname'] = "{$preRow['title']}"; //上一篇文章标题
  31. $this->PreNext['prewap'] = "<a href=\"view.php?aid={$preRow['id']}\" class=\"pg_a-son fl\" data-ignore=\"true\">上一条</a>  ";
  32.                 $this->PreNext['nextimg'] = "<a href='$mlink'><img src=\"{$preRow['litpic']}\" alt=\"{$preRow['title']}\"/></a> "; 
  33.             }
  34.             else
  35.             {
  36.                 $this->PreNext['next'] = "上一篇:没有了 ";
  37. $this->PreNext['nexturl'] = ""; //上一篇链接地址
  38. $this->PreNext['prewap'] = "<a href=\"javascript:;\" class=\"pg_a-son fl\" data-ignore=\"true\">没有了</a>  ";
  39.                 $this->PreNext['nextimg'] ="<img src=\"/templets/default/images/nophoto.jpg\" alt=\"对不起,没有上一图集了!\"/>";
  40.             }
  41.             if(is_array($nextRow))
  42.             {
  43.                 $mlink = GetFileUrl($nextRow['id'],$nextRow['typeid'],$nextRow['senddate'],$nextRow['title'],$nextRow['ismake'],$nextRow['arcrank'],
  44.                 $nextRow['namerule'],$nextRow['typedir'],$nextRow['money'],$nextRow['filename'],$nextRow['moresite'],$nextRow['siteurl'],$nextRow['sitepath']);
  45.                 $this->PreNext['pre'] = "下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
  46. $this->PreNext['preurl'] = "$mlink"; //上一篇链接地址
  47. $this->PreNext['prename'] = "{$nextRow['title']}"; //上一篇文章标题
  48. $this->PreNext['nextwap'] = "<a href=\"view.php?aid={$nextRow['id']}\" class=\"pg_a-son fr\" data-ignore=\"true\">下一条</a> ";
  49.                 $this->PreNext['preimg'] = "<a href='$mlink'><img src=\"{$nextRow['litpic']}\" alt=\"{$nextRow['title']}\"/></a> ";
  50.             }
  51.             else
  52.             {
  53.                 $this->PreNext['pre'] = "下一篇:没有了 ";
  54. $this->PreNext['preurl'] = ""; //上一篇链接地址
  55. $this->PreNext['nextwap'] = "<a href=\"javascript:;\" class=\"pg_a-son fr\" data-ignore=\"true\">没有了</a> ";
  56.                 $this->PreNext['preimg'] ="<a href='javascript:void(0)' alt=\"\"><img src=\"/templets/default/images/nophoto.jpg\" alt=\"对不起,没有下一图集了!\"/></a>";
  57.             }
  58.         }
  59.         if($gtype=='pre')
  60.         {
  61.             $rs =  $this->PreNext['pre'];
  62.         }
  63. else if($gtype=='prewap'){
  64.  
  65.             $rs =  $this->PreNext['prewap'];
  66.         }
  67.         else if($gtype=='preimg'){
  68.  
  69.             $rs =  $this->PreNext['preimg'];
  70.         }
  71.         else if($gtype=='next')
  72.         {
  73.             $rs =  $this->PreNext['next'];
  74.         }
  75. else if($gtype=='nextwap')
  76.         {
  77.             $rs =  $this->PreNext['nextwap'];
  78.         }
  79.         else if($gtype=='nextimg'){
  80.  
  81.             $rs =  $this->PreNext['nextimg'];
  82.         }
  83. else if($gtype=='preurl'){
  84.  
  85.              $rs =  $this->PreNext['preurl'];
  86.         }
  87.         else if($gtype=='prename'){
  88.  
  89.         $rs =  $this->PreNext['prename'];
  90.         }
  91.         else if($gtype=='nexturl'){
  92.  
  93.             $rs =  $this->PreNext['nexturl'];
  94.         }
  95.         else if($gtype=='nextname'){
  96.  
  97.             $rs =  $this->PreNext['nextname'];
  98.         }
  99.         else
  100.         {
  101.             $rs =  $this->PreNext['pre']." &nbsp; ".$this->PreNext['next'];
  102.         }
  103.         return $rs;
  104.     }

第二步:

文件替换好了 ,那就可以调用的了,调用标签如下:

  下一篇链接:{dede:prenext get='preurl'/} 上一篇链接:{dede:prenext get='nexturl'/}

  下一篇标题:{dede:prenext get='prename'/} 上一篇链接:{dede:prenext get='nextname'/}

注:因为调用顺序是按发布时间更新的,有人问为啥下一篇链接用 preurl,这个不做解释了,自己调用一下就明白了!

收藏
(3)

本文由 云模板 作者:PetitQ 发表,转载请注明来源!

也想出现在这里?联系我们
创客主机

发表评论

热销模板

Hub - 响应式可视化编辑企业官网WordPress汉化模板

Envato

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!

精品专区

Contact us all-in-one button with callback - 轻量级侧边按钮客服插件,允许设置自定义的提示语,还支持添加无限数量的联系方式,不仅支持国内的微信二维码、QQ等主流程序,还支持几乎所有国外的热门社交工具、及时聊天程序等,演示参考我们官网右下角客服按钮。

购买插件