zoukankan      html  css  js  c++  java
  • phpcms v9 wap手机门户站点内容页添加上一篇、下一篇的方法

    PHP源码修改:
    打开 phpcmsmoduleswapindex.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>

  • 相关阅读:
    金融风控100道面试题:传统银行开发转行互金top3公司并年薪40多万
    想学好矩阵?首先你要知道矩阵的历史!​
    什么是卷积?
    CNN的卷积核是单层的还是多层的?
    AI换脸之后“AI换声”来了!,一小时诈骗173万!
    介绍两个面试神器
    Github最火!程序员必须知道22大定律和法则
    SQL常用运算符
    SQL利用通配符进行模式查询
    隐藏DataList里面的某一行数据
  • 原文地址:https://www.cnblogs.com/lixihuan/p/7644773.html
Copyright © 2011-2022 走看看