首页站内杂志技术文摘
文章内容页

帝国CMS二次开发回复评论后文章才能完整显示的实现方法

  • 作者:美文苑
  • 来源: 原创
  • 发表于2022-01-26 21:50:01
  • 被阅读0
  • 回复评论后文章才能完整显示的实现方法
    1.在内容模板里面加入
    1. <div id="textshow"></div> 
    2.在模板尾部加入
    1. <script src="[!--news.url--]skin/news/js/jquery-1.7.2.min.js" type="text/javascript"></script> 
    2. <script> 
    3. (function (win, $) { 
    4.   $.listnews = { 
    5.     initGetData(index) { 
    6.         $.ajax({ 
    7.         url: '[!--news.url--]e/extend/text/?id=[!--id--]&classid=[!--classid--]'
    8.         type: 'get'
    9.         dataType: 'json'
    10.         success: function (jsonData) { 
    11.           var html = ''
    12.           if (jsonData.info) { 
    13.             jsonData.info.forEach(function (val) { 
    14.               html += `<div class="list_news_box">${val.newstext}</div>`; 
    15.             }) 
    16.             $('#textshow').append(html); 
    17.           } 
    18.         } 
    19.       }) 
    20.     }, 
    21.     init() { 
    22.       this.initGetData(); 
    23.     } 
    24.   } 
    25.   $.listnews.init(); 
    26. })(window, jQuery) 
    27. </script> 
    3.把下面代码,保存至e/extend/text/index.php,然后重新生成内容页面。
    1. <?php 
    2. require('../../class/connect.php'); //引入数据库配置文件和公共函数文件 
    3. require('../../class/db_sql.php'); //引入数据库操作文件 
    4. require('../../data/dbcache/class.php'); //引入栏目缓存文件 
    5. $link=db_connect(); //连接MYSQL 
    6. $empire=new mysqlquery(); //声明数据库操作类 
    7. $editor=1; //声明目录层次 
    8.  
    9. $lguserid=intval(getcvar('mluserid'));//登陆用户ID 
    10. $id=intval($_GET[id]);//文章ID 
    11. $classid=intval($_GET[classid]);//文章ID 
    12. $r=$empire->fetch1("select * from {$dbtbpre}ecms_news_data_1 where id='$id' limit 1");//获取附表文章内容 
    13. $s=$empire->fetch1("select count(userid) as tool from {$dbtbpre}enewspl_1 where id='$id' and userid='$lguserid' and checked='0' limit 1");//获取评论数 
    14.  
    15. if($s['tool']>0) 
    16. $newstext=stripslashes($r['newstext']); 
    17.         } 
    18. else 
    19. $newstext=esub(stripslashes($r['newstext']),300); 
    20.         } 
    21.  
    22. $json_arr[] = array( 
    23. "id"=>$r['id'], 
    24. "newstext"=>$newstext 
    25. ); //压入数组 
    26.  
    27. $result=array('info'=>$json_arr); 
    28. $json=json_encode($result); 
    29. echo $json; 
    30. db_close(); //关闭MYSQL链接 
    31. $empire=null//注消操作类变量 
    32. ?> 
    【审核人:站长】

        标题:帝国CMS二次开发回复评论后文章才能完整显示的实现方法

        本文链接:https://www.meiweny.cn/zazhi/zhongwangjiaocheng/29.html

        赞一下

        深度阅读

        • 您也可以注册成为美文苑的作者,发表您的原创作品、分享您的心情!

        阅读记录

          关注美文苑