第一步:
--------------------------------------------------------------------------------------
/**
* 取指定分类ID及类型的商品信息
* @access public
* @param string $cat_id 分类ID
* @param string $num 显示商品数量
* @param string $cat_type 显示商品类型 new新品,hot热销,best为精品,promote特价
* @param auther 邓士鹏(自定义函数)
* @return array
*/
function index_get_cat_id_goods_list($cat_id = '', $num = '',$cat_type='')
{
$sql = 'Select g.goods_id, g.cat_id,c.parent_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, goods_img, " .
"g.is_best, g.is_new, g.is_hot, g.is_promote " .
'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS c ON c.cat_id = g.cat_id ' .
"LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
"Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ".
$sql .= " AND (c.parent_id =" . $cat_id. " or g.cat_id = " . $cat_id ." or g.cat_id ". db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) .")";
if($cat_type!=''){
$sql .=" and is_".$cat_type."=1";
}else{
$sql .=" and is_best=0 and is_new=0 and is_hot=0 and is_promote=0";
}
$sql .= " order by g.goods_id desc LIMIT $num";
$res = $GLOBALS['db']->getAll($sql);
$goods = array();
foreach ($res AS $idx => $row)
{
$goods[$idx]['id'] = $row['article_id'];
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = $row['brand_name'];
$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'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb'];
$goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img'];
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
}
return $goods;
} ?>
--------------------------------------------------------------------------------------

第二步:

打开根目录的 index.php 文件,在适当位置添加以下代码:

比如在

$smarty->assign('shop_notice',     $_CFG['shop_notice']);       // 商店公告
--------添加
// new新品,hot热销,best为精品,promote特价
$smarty->assign('cat_id1_new_goods', index_get_cat_id_goods_list(1,10));
$smarty->assign('cat_id1_hot_goods', index_get_cat_id_goods_list(1,10,'hot'));
$smarty->assign('cat_id1_hot_goods', index_get_cat_id_goods_list(1,10,'promote'));
$smarty->assign('cat_id1_hot_goods', index_get_cat_id_goods_list(1,10,'best'));

根据自己的需要添加多条。

其中,1为分类ID,10为调用的数量。

如果不限制商品分类,分类ID可填 0

注:如果需要在 分类页调用,则在 category.php 文件中添加。

如果需要在 商品详情页调用,则在 good.php 文件中添加。

==================================================

<!--{foreach name=cat_id1_hot_goods from=$cat_id1_hot_goods item=goods}-->
<div style="padding-top: 8px;" class="new-tr">
<a target="_blank" href="{$goods.url}"><img width="116" height="130" border="0" alt="{$goods.name|escape:html}" src="{$goods.thumb}"></a>
<div class="right">
<a target="_blank" href="{$goods.url}">{$goods.name|escape:html}</a><br>
<span style="color: rgb(102, 102, 102); text-decoration: line-through;">市场价:{$goods.market_price}</span><br>
特卖价:<span style="color: rgb(255, 0, 0);">{$goods.shop_price}</span><br>
<span class="font-gmm"><a href="javascript:addToCart({$goods.id})">立即抢购</a></span>
</div>
<span class="new-line"></span>
</div>
<!--{/foreach}-->
												

最新文章

  1. 关于Python对齐问题
  2. Your intuition 你的直觉
  3. plink远程连接服务器进行编译
  4. C# winform的WebBrowser非常规编程(强烈推荐)
  5. 【翻译】How To Tango With Django 1.5.4 第一章
  6. GetProperties(BindingFlags)说明
  7. 使用EntityFramework连接 Mysql
  8. [译]36 Days of Web Testing(五)
  9. 捕android程序崩溃日志
  10. ACM题目推荐(刘汝佳书上出现的一些题目)[非原创]
  11. Cron表达式的详细用法
  12. 细说Handler
  13. Java第7次实验提纲(多线程)
  14. (11)Microsoft office Word 2013版本操作入门_word中表格操作
  15. ASP.NET Core 1.0、ASP.NET MVC Core 1.0和Entity Framework Core 1.0
  16. C# 委托知识总结
  17. 概率p输出1,概率1-p输出0,等概率输出0和1
  18. Linux基础命令---zip
  19. C语言多线程编程二
  20. H5应用程序缓存 - Cache manifest

热门文章

  1. java电影站点开发经验3
  2. @Validated数据校验
  3. Entity Framework Utility .ttinclude File
  4. Android WiFi/WiFi热点开发总结
  5. poj3071Football(概率期望dp)
  6. [Apple开发者帐户帮助]四、管理密钥(1)创建私钥以访问服务
  7. qW3xT.2挖矿病毒 解决过程及坑
  8. BN 详解和使用Tensorflow实现(参数理解)
  9. html body中的标签
  10. shell 实用命令学习