用户中心,我的收藏(收藏商品)下显示缩略图

2016-07-07 15:01 来源:www.chinab4c.com 作者:ecshop专家



默认模板上,[用户中心],我的收藏下没有缩略图,参考后台订单中显示缩略图,经测试出缩略图了,

具体参考下面:
1、修改includes\lib_clips.php文件
搜索function get_collection_goods,大约在31行位置
在下面的$sql中,插入字段g.goods_thumb,
  1. function get_collection_goods($user_id, $num = 10, $start = 0)
  2. {
  3. $sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.market_price, g.shop_price AS org_price, '.
  4. "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
  5. 'g.promote_price, g.promote_start_date,g.promote_end_date, c.rec_id, c.is_attention' .
  6. ' FROM ' . $GLOBALS['ecs']->table('collect_goods') . ' AS c' .
  7. " LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ".
  8. "ON g.goods_id = c.goods_id ".
  9. " LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
  10. "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
  11. " WHERE c.user_id = '$user_id' ORDER BY c.rec_id DESC";
复制代码


下移二十多行左右,大约在59行位置,增加一行
$goods_list[$row['goods_id']]['goods_thumb'] = $row['goods_thumb'];/*新增加一行,显示缩略图*/
增加后的效果如下:
  1. $goods_list[$row['goods_id']]['rec_id'] = $row['rec_id'];
  2. $goods_list[$row['goods_id']]['is_attention'] = $row['is_attention'];
  3. $goods_list[$row['goods_id']]['goods_id'] = $row['goods_id'];
  4. $goods_list[$row['goods_id']]['goods_name'] = $row['goods_name'];
  5. $goods_list[$row['goods_id']]['goods_thumb'] = $row['goods_thumb'];/*新增加一行,显示缩略图*/
复制代码


2、修改模板下的user_clips.dwt文件
在商品名称的前面,插入代码<img src="/{$goods.goods_thumb}" border="0" title="{$goods.goods_name|escape:html}" width="60" >
具体模板不同,插入的位置也不同(在下面代码的第11行)
插入后的代码,供参考
  1. <div class="blank"></div>
  2. <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#dddddd">
  3. <tr align="center">
  4. <th width="30%" bgcolor="#ffffff">{$lang.goods_name}</th>
  5. <th width="25%" bgcolor="#ffffff">{$lang.goods_attr}</th>
  6. <th width="15%" bgcolor="#ffffff">{$lang.goods_price}</th>
  7. <th width="30%" bgcolor="#ffffff">{$lang.handle}</th>
  8. </tr>
  9. <!--{foreach from=$goods_list item=goods}-->
  10. <tr>
  11. <td bgcolor="#ffffff"><img src="/{$goods.goods_thumb}" border="0" title="{$goods.goods_name|escape:html}" width="60" ><a href="{$goods.url}" class="f6">{$goods.goods_name|escape:html}</a></td>
  12. <td bgcolor="#ffffff">{$goods.goods_attr|nl2br}</a></td>
  13. <td bgcolor="#ffffff" align="center"><!-- {if $goods.promote_price neq ""} -->
  14. <span class="goods-price">{$goods.promote_price}</span>
  15. <!-- {else}-->
  16. <span class="goods-price">{$goods.shop_price}</span>
  17. <!--{/if}--> </td>
  18. <td align="center" bgcolor="#ffffff">
  19. <!-- {if $goods.is_attention} -->
复制代码

回答:
超级好,帅呆了

感谢分享,写的太好了。。。。

太好了 一定顶你 很实用哦

感谢分享