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>

  • 相关阅读:
    解决eclipse自动格式化影响svn提交的问题
    XShell下载安装并连接阿里云
    阿里云服务器购买选择
    三线程循环打印ABC流程解释
    eclipse个人开发较常用的快捷键
    eclipse调试的一些技巧
    Java序列化与反序列化
    vmware vsphere添加磁盘,不重启检测
    win10国内生态-恶心的经历
    本地win10 vmware 虚拟机centos7系统初始化网络配置
  • 原文地址:https://www.cnblogs.com/lixihuan/p/7644773.html
Copyright © 2011-2022 走看看