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

2021-09-07 0 1,001
  • 在库目录里增加一个文件:index_comments.lbi 里面有内容如下:
  • <?php
  • 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;
  • }
  • }
  • ?>
  • <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
  • <!–数据调用-最新评论开始 –>
  • <?php
  •    $this->assign(‘my_comments’,get_comments(10)); // 10 条数据
  • ?>
  •   <div class=”comments”>
  • <!–{foreach from=$my_comments item=comments}–>
  •       <div class=”t_l f_l”><a href=”goods.php?id={$comments.id_value}” target=”_blank”>
  • {$comments.content|truncate:15:””}</a></div><div class=”d_r f_r”>时间:
  • {$comments.add_time}</div>
  •       <!–{/foreach}–>
  •   </div>
  • 首页调用这个库文件就 OK 了.

本文章已结束,如转载请注明:汇站网 » ECShop 首页调用最新评论+(增加显示评论时间)

收藏 (0)

微信支付 微信扫一扫

支付宝支付 支付宝扫一扫

打赏二维码
点赞 (0)

站长资源下载中心-找源码上汇站

常见问题
  • 如果付款后没有弹出下载页面,多刷新几下,有问题联系客服!
查看详情
  • 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。
查看详情

相关文章

联系官方客服

为您解决烦忧 - 24小时在线 专业服务