• 全国400电话网上服务平台
    强大号码库资源任选,方便,快捷,快速开通。
    咨询热线:400-1100-266  

    dedecms5.7上一篇下一篇分开调用教程
    POST TIME:2017-11-13 01:22

    功能:
    1.文章内容页面上一篇、下一篇分两个标签调用,模板制作更方便!
    2.调用的上一篇、下一篇文章改为本文章所在栏目,而不是现在的全站。
    调用例子:

    <div style="text-align: left">↑{dede:preurl/}</div>
    <div style="text-align: left">↓{dede:nexturl/}</div>

    改法:打开includeinc_archives_view.php
    找到

    //--------------------------
    //获取上一篇,下一篇链接
    //--------------------------
    function GetPreNext()
    {
    $rs = "";
    $aid = $this->ArcID;
    $next = " dede_archives.ID>'$aid' order by dede_archives.ID asc ";
    $pre = " dede_archives.ID<'$aid' order by dede_archives.ID desc ";
    $query = "Select dede_archives.ID,dede_archives.title,
    dede_archives.typeid,dede_archives.ismake,dede_archives.senddate,dede_archives.arcrank,dede_archives.money,
    dede_arctype.typedir,dede_arctype.typename,dede_arctype.namerule,dede_arctype.namerule2,dede_arctype.ispart,
    dede_arctype.moresite,dede_arctype.siteurl 
    from dede_archives left join dede_arctype on dede_archives.typeid=dede_arctype.ID
    where ";
    $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 .= " 下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
    }
    else{
    $rs .= " 下一篇:没有了 ";
    }
    return $rs;
    }

    改为:

    //--------------------------
    //获取上一篇,下一篇链接
    //--------------------------
    function GetPreNext($pn=1)
    {
    $rs = "";
    $aid = $this->ArcID;
    $typeid = $this->Fields['typeid'];
    $next = " dede_archives.ID>'$aid' and dede_archives.typeid='$typeid' order by dede_archives.ID asc ";
    $pre = " dede_archives.ID<'$aid' and dede_archives.typeid='$typeid' order by dede_archives.ID desc ";
    $query = "Select dede_archives.ID,dede_archives.title,
    dede_archives.typeid,dede_archives.ismake,dede_archives.senddate,dede_archives.arcrank,dede_archives.money,
    dede_arctype.typedir,dede_arctype.typename,dede_arctype.namerule,dede_arctype.namerule2,dede_arctype.ispart,dede_arctype.moresite,dede_arctype.siteurl 
    from dede_archives left join dede_arctype on dede_archives.typeid=dede_arctype.ID
    where ";
    if($pn == 0){
    $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']);
    $prs .= "上一篇:<a href='$mlink'>{$preRow['title']}</a> ";
    }
    else{
    $prs .= "上一篇:没有了 ";
    }
    return $prs;
    }
    else{
    $nextRow = $this->dsql->GetOne($query.$next);
    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']);
    $nrs .= "下一篇:<a href='$mlink'>{$nextRow['title']}</a> ";
    }
    else{
    $nrs .= "下一篇:没有了 ";
    }
    return $nrs;
    }
    }

    找到:

    //上下篇链接
    else if($tagname=="prenext"){
    $this->dtp->Assign($tagid,$this->GetPreNext());
    }

    改为:

    //上下篇链接
    else if($tagname=="preurl"){
    $this->dtp->Assign($tagid,$this->GetPreNext(0));
    }
    else if($tagname=="nexturl"){
    $this->dtp->Assign($tagid,$this->GetPreNext());
    }

    
    Copyright © 2003-2016
    时间:9:00-21:00 (节假日不休)
    版权所有:巨人网络(扬州)科技有限公司
    总部地址:江苏省信息产业基地11号楼四层
    《增值电信业务经营许可证》 苏B2-20120278
    X

    截屏,微信识别二维码

    微信号:veteran88

    (点击微信号复制,添加好友)

     打开微信

    微信号已复制,请打开微信添加咨询详情!