以下的方式我沒實測過,不確定是否正確,要做之前請先做好備份:
打開includes/lib_goods.php,大約在289行附近找到
- //取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
- $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .
- "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
- "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd " .
- 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
- "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
- "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ";
- $type_merge = array_merge($type_array['new'], $type_array['best'], $type_array['hot']);
- $type_merge = array_unique($type_merge);
- $sql .= ' WHERE g.goods_id ' . db_create_in($type_merge);
- $sql .= ' ORDER BY g.sort_order, g.last_update DESC';
- $result = $GLOBALS['db']->getAll($sql);
- foreach ($result AS $idx => $row)
- {
- if ($row['promote_price'] > 0)
- {
- $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
- $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
- }
- else
- {
- $goods[$idx]['promote_price'] = '';
- }
- $goods[$idx]['id']= $row['goods_id'];
- $goods[$idx]['name']= $row['goods_name'];
- $goods[$idx]['brief']= $row['goods_brief'];
- $goods[$idx]['brand_name']= isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
- $goods[$idx]['goods_style_name']= add_style($row['goods_name'],$row['goods_name_style']);
- $goods[$idx]['short_name']= $GLOBALS['_CFG']['goods_name_length'] > 0 ?
- sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
- $goods[$idx]['short_style_name']= add_style($goods[$idx]['short_name'],$row['goods_name_style']);
- $goods[$idx]['market_price'] = price_format($row['market_price']);
- $goods[$idx]['shop_price']= price_format($row['shop_price']);
- $goods[$idx]['thumb']= get_image_path($row['goods_id'], $row['goods_thumb'], true);
- $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
- $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
- if (in_array($row['goods_id'], $type_array['best']))
- {
- $type_goods['best'][] = $goods[$idx];
- }
- if (in_array($row['goods_id'], $type_array['new']))
- {
- $type_goods['new'][] = $goods[$idx];
- }
- if (in_array($row['goods_id'], $type_array['hot']))
- {
- $type_goods['hot'][] = $goods[$idx];
- }
- }
复制代码
改成
- //取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
- $sql = 'SELECT g.goods_id, cat_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .
- "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
- "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd " .
- 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
- "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
- "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ";
- $type_merge = array_merge($type_array['new'], $type_array['best'], $type_array['hot']);
- $type_merge = array_unique($type_merge);
- $sql .= ' WHERE g.goods_id ' . db_create_in($type_merge);
- $sql .= ' ORDER BY g.sort_order, g.last_update DESC';
- $result = $GLOBALS['db']->getAll($sql);
- foreach ($result AS $idx => $row)
- {
- if ($row['promote_price'] > 0)
- {
- $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
- $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
- }
- else
- {
- $goods[$idx]['promote_price'] = '';
- }
- $goods[$idx]['id']= $row['goods_id'];$goods[$idx]['cat_id'] = $row['cat_id'];
- $goods[$idx]['name']= $row['goods_name'];
- $goods[$idx]['brief']= $row['goods_brief'];
- $goods[$idx]['brand_name']= isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
- $goods[$idx]['goods_style_name']= add_style($row['goods_name'],$row['goods_name_style']);
- $goods[$idx]['short_name']= $GLOBALS['_CFG']['goods_name_length'] > 0 ?
- sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
- $goods[$idx]['short_style_name']= add_style($goods[$idx]['short_name'],$row['goods_name_style']);
- $goods[$idx]['market_price'] = price_format($row['market_price']);
- $goods[$idx]['shop_price']= price_format($row['shop_price']);
- $goods[$idx]['thumb']= get_image_path($row['goods_id'], $row['goods_thumb'], true);
- $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
- $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
- if (in_array($row['goods_id'], $type_array['best']))
- {
- $type_goods['best'][] = $goods[$idx];
- }
- if (in_array($row['goods_id'], $type_array['new']))
- {
- $type_goods['new'][] = $goods[$idx];
- }
- if (in_array($row['goods_id'], $type_array['hot']))
- {
- $type_goods['hot'][] = $goods[$idx];
- }
- }
复制代码
把你原來的recommend_best.lbi內容
-
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <!-- {if $best_goods} -->
- <!--{foreach from=$categories item=cat}-->
- <div class="box box_1">
-
- <a href="../search.php?intro=best" >精品推荐</a>
- <div class="cat_tit"> <span><a href="{$cat.url}">{$cat.name|escape:html}</a></span> <ahref="../search.php?intro=best">更多>></a></div>
- <div class="goods_cat">
- <div class="clearfix goodsBox" >
-
- <!--{foreach from=$cat_list item=goods}-->这一句该如何写才能遍历对应的商品
- <div class="goodsItem ">
- <a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name|escape:html}" class="goodsimg" /></a><br />
- <p><a href="{$goods.url}" title="{$goods.name|escape:html}">{$goods.short_name|escape:html}</a></p>
- <!-- {if $goods.promote_price neq ""} -->
- <font class="shop_s">{$goods.promote_price}</font>
- <!-- {else}-->
- <font class="shop_s">{$goods.shop_price}</font>
- <!--{/if}-->
- </div>
- <!--{/foreach}-->
-
- </div>
- </div>
- </div>
- <div class="blank"></div>
- <!--{/foreach}-->
- <!-- {/if} -->
复制代码
全部改為
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <!-- {if $best_goods} -->
- <!--{foreach from=$categories item=cat}-->
- <div class="box box_1">
- <a href="../search.php?intro=best" >精品推荐</a>
- <div class="cat_tit"> <span><a href="{$cat.url}">{$cat.name|escape:html}</a></span> <a href="../search.php?intro=best">更多>></a> </div>
- <div class="goods_cat ">
- <div class="clearfix goodsBox " >
- <!--{foreach from=$best_goods item=goods}-->
- <!--{if $cat.id eq$goods.cat_id}-->
- <div class="goodsItem ">
- <a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name|escape:html}" class="goodsimg" /></a><br />
- <p><a href="{$goods.url}" title="{$goods.name|escape:html}">{$goods.short_name|escape:html}</a></p>
- <!-- {if $goods.promote_price neq ""} -->
- <font class="shop_s">{$goods.promote_price}</font>
- <!-- {else}-->
- <font class="shop_s">{$goods.shop_price}</font>
- <!--{/if}-->
- </div>
- <!--{/if}-->
- <!--{/foreach}-->
- </div>
- </div>
- </div>
- <div class="blank"></div>
- <!--{/foreach}-->
- <!-- {/if} -->
复制代码
|