ECSHOP首页调用显示最新商品评论

2016-06-13 13:05 来源:www.chinab4c.com 作者:ecshop专家

ECSHOP首页显示最新评论,首页调用商品评论新建立一个 index_comments.lbi 库文件 然后在index.dwt 要显示的位置调用:     index_comments.lbi 内容为: table('comment') .             ' AS a,'. $GLOBALS['ecs']->table('goods') .'AS b WHERE a.status = 1 AND a.parent_id = 0 and LENGTH(a.content)>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;   }   //echo $sql;           $res = $GLOBALS['db']->getAll($sql);   $comments = array();   foreach ($res AS $idx => $row)   {    $comments[$idx]['add_time']      = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);    $comments[$idx]['content']       = $row['content'];    $comments[$idx]['id_value']      = $row['id_value'];    $comments[$idx]['goods_thumb']   = get_image_path($row['goods_id'], $row['goods_thumb'], true);    $comments[$idx]['goods_name']    = $row['goods_name'];   }   return $comments; } } ?>        assign('my_comments',get_comments(10)); // 数据条数 ?>    

             
  • {$comments.add_time}       {$comments.content|truncate:10:""}      
          
           {$comments.goods_name|escape:html}       
         
         
  •