• 技术文章 >后端开发 >php教程

    phpcms2008添加下一篇上一篇的功能

    2016-06-13 13:05:48原创503
    phpcms2008添加上一篇下一篇的功能


    第一步:修改show.php
    在代码
    if(!$C['defaultchargepoint'] && !$r['readpoint'])
    前面增加代码
    //
    //上一篇文章
    $more_pre = $db->get_one("SELECT title,url FROM `".DB_PRE."content` WHERE `contentid`<$contentid and `catid`='{$r['catid']}' order by contentid desc limit 0,1");
    if(empty($more_pre)) {
    $more_pre['title']='没有了';
    $more_pre['url']='';
    }
    //下一篇文章
    $more_next = $db->get_one("SELECT title,url FROM `".DB_PRE."content` WHERE `contentid`>$contentid and `catid`='{$r['catid']}' order by contentid asc limit 0,1");
    if(empty($more_next)) {
    $more_next['title']='没有了';
    $more_next['url']='';
    }
    //


    第二步:修改include/html.class.php中的show函数
    在代码
    if(strpos($content, '[page]') !== false)
    前增加代码:
    //
    global $db;
    //上一篇文章
    $more_pre = $db->get_one("SELECT title,url FROM `".DB_PRE."content` WHERE `contentid`<$contentid and `catid`='$catid' order by contentid desc limit 0,1");
    if(empty($more_pre)) {
    $more_pre['title']='没有了';
    $more_pre['url']='';
    }
    //下一篇文章
    $more_next = $db->get_one("SELECT title,url FROM `".DB_PRE."content` WHERE `contentid`>$contentid and `catid`='$catid' order by contentid asc limit 0,1");
    if(empty($more_next)) {
    $more_next['title']='没有了';
    $more_next['url']='';
    }
    //


    第三步:在模板目录/phpcms/show.html文件中您认为合适的位置添加



    第四步:在您的CSS样式文件中添加
    /***上一篇下一篇文章链接(fke.la)***/
    .moreArticle{
    margin:5px 0px;width:100%;
    font-size:12px;clear:both;
    }
    .moreArticle ul{width:100%;}
    .moreArticle ul li{width:100%;height:22px;line-height:22px;}

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:more contentid title pre gt
    上一篇: 15万条数据的查询解决办法 下一篇: php 字符串瓜分几种方式
    PHP编程就业班

    相关文章推荐

    • php Swoole实现毫秒定时计划任务(详解)• 【DTM】PHP协程客户端v0.1 beta版本发布啦!• 第五行出错,哪里符号有关问题 • PHP Date()函数详细参数• 帮忙解答 谢谢

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网