dedecms實現欄目內的文章上下鏈接

使用dedecms的時候,當打開某篇文章的時候,底部會有“上一篇”“下一篇”的鏈接信息,默認情況下,上下鏈接信息並沒有區分欄目的屬性,那麼需要實現本欄目內的上下篇,如何實現呢?

答案是修改程序。

修改:include/inc_archives_view.php

修改function GetPreNext()函數爲:

  //--------------------------
  //獲取上一篇,下一篇鏈接
  //--------------------------
  function GetPreNext()
  {
   $rs = "";
   $aid = $this->ArcID;
  $rid = $this->Fields['typeid'];
   $next = " #@__archives.ID>'$aid' and #@__archives.typeID='$rid' order by #@__archives.ID asc ";
   $pre = " #@__archives.ID<'$aid' and #@__archives.typeID='$rid' order by #@__archives.ID desc ";

   $query = "Select #@__archives.ID,#@__archives.title,
   #@__archives.typeid,#@__archives.ismake,#@__archives.senddate,#@__archives.arcrank,#@__archives.money,
  #@__arctype.typedir,#@__arctype.typename,#@__arctype.namerule,#@__arctype.namerule2,#@__arctype.ispart,
  #@__arctype.moresite,#@__arctype.siteurl
  from #@__archives left join #@__arctype on #@__archives.typeid=#@__arctype.ID
  where ";
  //echo $query.$next."<br />";
  $nextRow = $this->dsql->GetOne($query.$next);
  $preRow = $this->dsql->GetOne($query.$pre);
  if(is_array($preRow)){
    $mlink = GetFileUrl($preRow['ID'],$preRow['typeid'],$preRow['senddate'],$preRow['title'],$preRow['ismake'],$preRow['arcrank'],$preRow['namerule'],$preRow['typedir'],$preRow['money'],true,$preRow['siteurl']);
       $rs .= "上一篇:<a href='$mlink'>{$preRow['title']}</a> ";
  }
  else{
   $rs .= "上一篇:沒有了 ";
  }
  if(is_array($nextRow)){
    $mlink = GetFileUrl($nextRow['ID'],$nextRow['typeid'],$nextRow['senddate'],$nextRow['title'],$nextRow['ismake'],$nextRow['arcrank'],$nextRow['namerule'],$nextRow['typedir'],$nextRow['money'],true,$nextRow['siteurl']);
       $rs .= " &nbsp; 下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
  }
  else{
   $rs .= " &nbsp; 下一篇:沒有了 ";
   }
  return $rs;
  }  

基本思想就是獲得欄目ID,然後查詢的時候加上欄目ID的限制。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章