怎样在首页调用商品详细描述?

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

怎样在首页调用商品详细描述?说详细说哦,最好贴代码,我是新手

回答:


首页商品,有很多区域,促销、新品、热卖、推荐、分类商品、等等等等,你应该具体说明你想在首页哪个区域的商品调用详细描述。
以新品、推荐、热卖为例

修改 includes/lib_goods.php 文件,找到 get_recommend_goods 函数部分
修改下面代码,红色为新增加的

$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.goods_desc, 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]['goods_desc']= sub_str(strip_tags($row['goods_desc']), 50);

$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']);

......................


接下来就是在
/themes/default/library/recommend_best.lbi
/themes/default/library/recommend_hot.lbi
/themes/default/library/recommend_new.lbi
几个文件中的调用了。。

这么调用 {$goods.goods_desc}
主要调用代码 要放在循环里面

以上只是 新品、 热卖、 推荐、里的修改方法,首页其他区域商品修改方法雷同,举一反三吧

很容易。先取得goods_desc,然后再显示