ECShop H5微商城
ECShop APP商城
ECshop4.0商业授权
ECShop源码全能套餐
ECMall全能套餐(含主机)
ECMall3.0功能定制
ECShop商城小程序
ECShop二开定制
ECShop授权套餐
ECShop装修市场
ECMall基础套餐(PC+H5)
ECMall3.0商业授权
返回列表 发帖

[共享] 首页显示产品评论 新手分享

本帖最后由 eh99 于 2014-6-13 16:20 编辑

1.首先 在../httpdocs/themes/lativ/library
   新增 index_comments.lbi 這個庫項目,

代碼如下
  1. <?php
  2. if(!function_exists("get_comments")){
  3. function get_comments($num)
  4. {
  5. $sql = 'SELECT a.*,b.goods_id,b.goods_thumb,b.goods_name FROM '. $GLOBALS['ecs']->table('comment') .
  6. ' 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 '.
  7. ' ORDER BY a.add_time DESC';
  8. if ($num > 0)
  9. {
  10. $sql .= ' LIMIT ' . $num;
  11. }
  12. //echo $sql;

  13. $res = $GLOBALS['db']->getAll($sql);
  14. $comments = array();
  15. foreach ($res AS $idx => $row)
  16. {
  17. $comments[$idx]['user_name'] = $row['user_name']; /*呼叫用戶名*/
  18. $comments[$idx]['content'] = $row['content'];/*呼叫用戶評論*/
  19. $comments[$idx]['id_value'] = $row['id_value'];
  20. $comments[$idx]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);/*呼叫被評論的產品縮圖*/
  21.    $comments[$idx]['goods_name'] = $row['goods_name'];/*呼叫被評論的產品名稱*/
  22.   }
  23. return $comments;
  24. }
  25. }
  26. ?>
  27. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  28. <!--?? -->

  29. <?php
  30. $this->assign('my_comments',get_comments(10)); // /*呼叫評論數目*/
  31. ?>
  32. <marquee scrollamount="2.5" direction="right"> /*scrollamount=評論軸滑動速度;direction=產品縮圖跑的方向*/
  33. <!--{foreach from=$my_comments item=comments}-->
  34. <td width="65" height="50" align="left"><a href="goods.php?id={$comments.id_value}" target="_blank"><img src="{$comments.goods_thumb}" border="1" width="60" height="60" style=" border:1px #CCCCCC solid;"/></a></td>
  35. <td width="130" align="left">
  36. <div style="height:3px; overflow:hidden;"> </div>
  37. <div>{$comments.user_name|truncate:100:""}</div>
  38. <div><a href="goods.php?id={$comments.id_value}" target="_blank"><font style=" color:#FF0000; font-size:14px;">{$comments.goods_name}</font></a></div>
  39. <div>{$comments.content|truncate:100:""}</div>
  40. <div style="color:#999999;">{$comments.add_time}</div>
  41. </td>
  42. </tr>
  43. <!--{/foreach}-->
  44. </marquee>
复制代码



2.到 /httpdocs/themes/lativ 下,
  找到 index.dwt 檔案修改
  在第333行加入 下面程式碼呼叫 index_comments.lbi

  1. <div style="margin-bottom:20px" id="focus">
  2. <!-- #BeginLibraryItem "/library/index_comments.lbi" --><!-- #EndLibraryItem -->
  3. </div>
复制代码



3.成功啦!www.eh99.com.tw  歡迎有問題可以問我喔!
  不過我這次針對框架中間的方法,由於俺還是新手其他例如右側左側上方的方法還沒研究出來;
希望有高手指導囉!

ecshop說明圖.gif
2014-6-13 16:11
ecshop說明圖.gif
ECShop下载                             ECShop4.0商业授权

不错啊这样做得
ECShop下载                             ECShop4.0商业授权

TOP

返回列表