栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP > php开源框架 > ecshop

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

ecshop 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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了.

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/218780.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号