最新公告
  • 欢迎您光临站壳网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入我们
  • ECShop首页调用最新评论+(增加显示评论时间)

    在Ecshop首页上显示最新评论(评论内容&时间),在Ecshop首页上显示最新评论(评论内容时间),ECshop首页调用产品评论,ECShop首页调用最新评论+(增加显示评论时间),下面小编来给大家介绍一下,一起来了解一下吧!

    在库目录里增加一个文件: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了.

    更多教程关注FF推源码网。

    • 18785会员总数(位)
    • 5454资源总数(个)
    • 98本周发布(个)
    • 4 今日发布(个)
    • 1509稳定运行(天)

    提供最优质的资源集合

    立即查看 了解详情