ecshop 全站评论首页显示

ecshop插件 为你提供

如何在首页调用商品的评论,只需要构造一个 index_comments.lbi文件, 然后在首页引入就可以了,超简单;

命名为: index_comments.lbi


<?php
 
if(!function_exists("get_comments")){
function get_comments($num)
{
   $sql = 'SELECT a.*,b.goods_id,b.goods_thumb,b.goods_name FROM '. $GLOBALS['ecs']->table('comment') .
			' AS a,'. $GLOBALS['ecs']->table('goods') .'AS b WHERE a.status = 1 AND a.parent_id = 0 and a.comment_type=0 and a.id_value=b.goods_id '.
			' ORDER BY a.add_time DESC';
  if ($num > 0)
  {
   $sql .= ' LIMIT ' . $num;
  }
 
  $res = $GLOBALS['db']->getAll($sql);
  $comments = array();
  foreach ($res AS $idx => $row)
  {
 
   $comments[$idx]['add_time']	   = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']);//评论时间
   $comments[$idx]['content']	   = $row['content'];  //评论内容
   $comments[$idx]['id_value']	   = $row['id_value'];	//产品id
   $comments[$idx]['goods_thumb']  = get_image_path($row['goods_id'], $row['goods_thumb'], true);//产品图片
   $comments[$idx]['goods_name']	   = $row['goods_name'];//产品名称
  }
  return $comments;
}
}
 
?>
 
 
<!--数据调用-最新评论开始 -->
<?php
   $this->assign('comments',get_comments(6)); // 数据条数  6 参数,调用条数
?>
 
	//下面的内容根据自己的模板去嵌套就好了
	<!--{foreach from=$comments item=comments}-->
	评论内容:20个字母:{$comments.content|truncate:20:""}
	评论时间:{$comments.add_time}
	产品图片:{$comments.goods_thumb}
	产品名称:{$comments.id_value}
	产品id:{$comments.goods_name}
 
	<!--{/foreach}-->
  	</div>


调用方法: 在任何dwt 页面引入即可:

文章如转载,请注明:转载自:让代码飞扬-PHPecshop插件本文链接地址:http://www.wangzhibo.com/share/1259.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值