muban大师 发表于 2015-12-25 10:13:32

ECShop首页调用最新评论+(增加显示评论时间)

在库目录里增加一个文件:index_comments.lbi 里面有内容如下:
       
       
        if(!function_exists("get_comments")){
        function get_comments($num)
        {
           $sql = 'SELECT * FROM '. $GLOBALS['ecs',->table('comment') .
                    ' WHERE status = 1 AND parent_id = 0 and comment_type=0 '.
                    ' ORDER BY add_time DESC';
          if ($num > 0)
          {
           $sql .= ' LIMIT ' . $num;
          }
          //echo $sql;
                
          $res = $GLOBALS['db',->getAll($sql);
          $comments = array();
          foreach ($res AS $idx => $row)
          {
           $comments[$idx,['add_time',       = $comments[$idx,['add_time',       = local_date
        ($GLOBALS['_CFG',['time_format',, $row['add_time',);
           $comments[$idx,['user_name',       = $row['user_name',;
           $comments[$idx,['content',       = $row['content',;
           $comments[$idx,['id_value',       = $row['id_value',;
          }
          return $comments;
        }
        }
        ?>
       
             
       
           $this->assign('my_comments',get_comments(10)); // 10条数据
        ?>
          
       
              [url=,
        {$comments.content|truncate:15:""}时间:
        {$comments.add_time}
             
          
       
       
       
        首页调用这个库文件就OK了.
页: [1]
查看完整版本: ECShop首页调用最新评论+(增加显示评论时间)