ECSHOP自定义函数,商品名称前台不显示
函数的实现内容$sql="SELECTgoods_name,goods_img,shop_price,market_price,goods_id,goods_thumbF...
函数的实现内容
$sql="SELECT goods_name,goods_img,shop_price,market_price,goods_id,goods_thumb FROM ".$GLOBALS['ecs']->table('goods'). " WHERE cat_id =" . $list1 . " ORDER BY last_update DESC LIMIT 0 , 8 ";
$res = $GLOBALS['db']->getAll($sql);
$list=array();
foreach($res as $idx=>$row)
{
$list[$idx]['goods_name']=$row['goods_name'];
$list[$idx]['goods_img']=get_image_path($row['goods_id'], $row['goods_img']);
$list[$idx]['url']=build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
}
return $list;
前台的实现部分,用PRINT_R打印,显示正常,是有数据的
<!--{foreach from=$cat_goods_1 item=goods}-->
<li><a href="{$goods.url}" class="Tit" title="{$goods.goods_name}">{$goods.goods_name}</a></li>
<!--{/foreach}-->
在INDEX.PHP中做的处理
$smarty->assign('cat_goods_1', get_cat_goods(1)); 展开
$sql="SELECT goods_name,goods_img,shop_price,market_price,goods_id,goods_thumb FROM ".$GLOBALS['ecs']->table('goods'). " WHERE cat_id =" . $list1 . " ORDER BY last_update DESC LIMIT 0 , 8 ";
$res = $GLOBALS['db']->getAll($sql);
$list=array();
foreach($res as $idx=>$row)
{
$list[$idx]['goods_name']=$row['goods_name'];
$list[$idx]['goods_img']=get_image_path($row['goods_id'], $row['goods_img']);
$list[$idx]['url']=build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
}
return $list;
前台的实现部分,用PRINT_R打印,显示正常,是有数据的
<!--{foreach from=$cat_goods_1 item=goods}-->
<li><a href="{$goods.url}" class="Tit" title="{$goods.goods_name}">{$goods.goods_name}</a></li>
<!--{/foreach}-->
在INDEX.PHP中做的处理
$smarty->assign('cat_goods_1', get_cat_goods(1)); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询