ecshop 首页如何调用积分商城里面的的商品

一、调用热门积分商品的函数

/**
* 获得积分商城热门商品
*
* @param   int      $maxtop        列出条数
* @return array
*/
function exchange_gets_goods($maxtop)
{
    /* 获得热门积分商品列表 */
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, eg.exchange_integral, '
.' g.goods_type,g.goods_brief, g.goods_thumb, g.goods_img, eg.is_hot ' 
.' FROM `ecshop`.`ecshop_exchange_goods` AS eg LEFT JOIN `ecshop`.`ecshop_goods` AS g ON g.goods_id = eg.goods_id LEFT JOIN `ecshop`.`ecshop_brand` AS b ON b.brand_id = g.brand_id '
.' WHERE eg.is_exchange = 1 AND g.is_delete = 0 AND eg.is_hot = 1 ORDER BY g.sort_order, g.last_update DESC limit ';
$sql.=$maxtop;
$res = $GLOBALS['db']->getAll($sql);
    $arr = array();
   foreach($res AS $idx => $row)
    {
$arr[$idx]['name']              = $row['goods_name'];
$arr[$idx]['goods_brief']       = $row['goods_brief'];
$arr[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$arr[$idx]['exchange_integral'] = $row['exchange_integral'];
$arr[$idx]['type']              = $row['goods_type'];
$arr[$idx]['goods_thumb']       = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$idx]['goods_img']         = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$idx]['url']               = build_uri('exchange_goods', array('gid'=>$row['goods_id']), $row['goods_name']);
    }
    return $arr;
}

->

二、 //调用积分商城的商品,在index.php中加入

$smarty -> assign('goods_exchange_list',exchange_gets_goods(6));

三、显示模板,在index.dwt中加入

View Code
<!--积分商城列表-->
<div class="modTitle clearfix">
<span class="left"></span><span class="right"></span>
<div class="f_l">积分兑换</div>
<div class="more">
<a href="/exchange.php" target="_blank"><img src="../images/bnt_more_1.gif" class="more" alt="更多"></a></div>
</div>
<div class="modBox clearfix">
<!--{foreach name=goods_exchange_list from=$goods_exchange_list item=exchange_goods}-->
<div class="goodsMod">
<a href="{$exchange_goods.url}" target="_blank"><img src="{$exchange_goods.goods_thumb}" alt="{$exchange_goods.goods_name}" /></a><br />
   <p><a href="{$exchange_goods.url}" target="_blank">
   <!-- {if $exchange_goods.goods_style_name} -->
   <font class="f3">{$exchange_goods.goods_style_name}</font><br />
   <!-- {else} -->
   <font class="f3">{$exchange_goods.goods_name}</font><br />
   <!-- {/if} -->
   </a>
   <!-- {if $exchange_goods.goods_brief} -->
   {$lang.goods_brief}{$exchange_goods.goods_brief}<br />
   <!-- {/if} --></p>
{$lang.exchange_integral}<font class="price">{$exchange_goods.exchange_integral}</font>
</div>
<!--{/foreach}-->
</div>

 

posted @ 2012-08-17 22:55  沐雪架构师  阅读(1165)  评论(0编辑  收藏  举报