phpcms v9 wap手机门户站点内容页添加上一篇、下一篇的方法

    发布时间:2021-01-16 03:38:28

    阅读量

    广告位招租,联系QQ:9056731

    PHP源码修改:
    打开 phpcms\modules\wap\index.php 文件
    找到

    if(!$r || $r['status'] != 99) showmessage(L('info_does_not_exists'),'blank');

    在其下面添加

    //上一篇
    $previous_page = $this->db->get_one("`catid` = '$catid' AND `id`<'$id' AND `status`=99",'*','id DESC');
    //下一篇
    $next_page = $this->db->get_one("`catid`= '$catid' AND `id`>'$id' AND `status`=99");
    //当前页为第一篇时:再点击上一篇仍然显示第一篇
    if(empty($previous_page)) {
    $previous_page = $this->db->get_one("`catid` = '$catid' AND `id`='$id' AND `status`=99",'*','id DESC');
    }
    //当前页为最后一篇时:再点击下一篇仍然显示最后一篇
    if(empty($next_page)) {
    $next_page = $this->db->get_one("`catid`= '$catid' AND `id`='$id' AND `status`=99");
    }

     

     

    使用排序的上一篇下一篇解决办法

    $listorder = $r['listorder'];
    //上一篇
    $previous_page = $this->db->get_one("`catid` = '$catid' AND `listorder`<'$listorder' AND `status`=99",'*','listorder desc');
    //下一篇
    $next_page = $this->db->get_one("`catid`= '$catid' AND `listorder`>'$listorder' AND `status`=99",'*','listorder asc');
    //当前页为第一篇时:再点击上一篇仍然显示第一篇
    if(empty($previous_page)) {
    $previous_page = $this->db->get_one("`catid` = '$catid' AND `listorder`='$listorder' AND `status`=99",'*','listorder desc');
    }
    //当前页为最后一篇时:再点击下一篇仍然显示最后一篇
    if(empty($next_page)) {
    $next_page = $this->db->get_one("`catid`= '$catid' AND `listorder`='$listorder' AND `status`=99",'*','listorder asc');
    }


    模板调用:


    <a href="{WAP_SITEURL}&a=show&catid={$catid}&typeid=1&id= {$previous_page[id]}">上一篇:{$previous_page[title]}</a>

    <a href="{WAP_SITEURL}&a=show&catid={$catid}&typeid=1&id= {$next_page[id]}">上一篇:{$next_page[title]}</a>

    广告位招租,联系QQ:9056731
    留言与评论(共有 0 条评论)
       
    验证码: