调用id问题 求大侠指导

2016-07-07 16:03 来源:www.chinab4c.com 作者:ecshop专家

QQ截图20121228150337.jpg 如果我想调用商品分类这些在 QQ截图20121228150635.jpg 热卖改成手机类型还有小分类也改成手机的 要如何写?求高手只招

回答:
找到数据 改成自己想要的数据就是了,热卖页面应该是recommend_hot.lbi 你要说数据怎么来 ,那就自己研究吧

找到数据 改成自己想要的数据就是了,热卖页面应该是recommend_hot.lbi 你要说数据怎么来 ,那就自己研究吧
lj19870908 发表于 2012-12-28 14:40

算了 我还是给你提供个我写的方法吧 哎
  1. /**
  2. * 获得指定分类下的商品
  3. *
  4. * @accesspublic
  5. * @paraminteger$cat_id分类ID
  6. * @paraminteger$num显示数量
  7. * @paraminteger$cat_num 二级分类显示数量
  8. * @returnarray
  9. */
  10. function gets_cat_goods($cat_id, $num = 0,$cat_num=0)
  11. {
  12. $children = get_children($cat_id);

  13. $sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' .
  14. "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
  15. 'g.promote_price, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img ' .
  16. "FROM " . $GLOBALS['ecs']->table('goods') . ' AS g '.
  17. "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
  18. "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
  19. 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND '.
  20. 'g.is_delete = 0 AND (' . $children . 'OR ' . get_extension_goods($children) . ') ';

  21. $order_rule = empty($order_rule) ? 'ORDER BY g.sort_order, g.goods_id DESC' : $order_rule;
  22. $sql .= $order_rule;
  23. if ($num > 0)
  24. {
  25. $sql .= ' LIMIT ' . $num;
  26. }
  27. $res = $GLOBALS['db']->getAll($sql);

  28. $goods = array();
  29. foreach ($res AS $idx => $row)
  30. {
  31. if ($row['promote_price'] > 0)
  32. {
  33. $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
  34. $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
  35. }
  36. else
  37. {
  38. $goods[$idx]['promote_price'] = '';
  39. }

  40. $goods[$idx]['id']= $row['goods_id'];
  41. $goods[$idx]['name']= $row['goods_name'];
  42. $goods[$idx]['brief']= $row['goods_brief'];
  43. $goods[$idx]['market_price'] = price_format($row['market_price']);
  44. $goods[$idx]['short_name']= $GLOBALS['_CFG']['goods_name_length'] > 0 ?
  45. sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
  46. $goods[$idx]['shop_price']= price_format($row['shop_price']);
  47. $goods[$idx]['thumb']= get_image_path($row['goods_id'], $row['goods_thumb'], true);
  48. $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
  49. $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
  50. }

  51. $cat['goods'] = $goods;
  52. /* 分类信息 */
  53. $sql = 'SELECT cat_name FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '$cat_id'";
  54. $cat['name'] = $GLOBALS['db']->getOne($sql);
  55. $cat['url']= build_uri('category', array('cid' => $cat_id), $cat['name']);
  56. $cat['id']= $cat_id;
  57. if($cat_num>0){
  58. $cat['cat_names']=gets_cat_names($cat_id,$cat_num);
  59. }
  60. return $cat;
  61. }

  62. /**
  63. * 获得二级分类的名称
  64. *
  65. * @accesspublic
  66. * @paraminteger$cat_id分类ID
  67. * @paraminteger$num数量
  68. * @returnarray
  69. */
  70. function gets_cat_names($cat_id, $num = 0)
  71. {


  72. $sql = "SELECT cat_name FROM " . $GLOBALS['ecs']->table('category') ." WHERE is_show = 1 AND parent_id ='$cat_id' order by sort_order asc LIMIT $num ";
  73. $res = $GLOBALS['db']->getAll($sql);
  74. return $res;
  75. }
复制代码



抱歉我是一个新手

我就是想调用小分类不是全部的分类代码是怎么样的?就例如 我建了一个手机大类下面有诺基亚 iPhone 三星等把这些显示在那条框里面 QQ截图20121228150635.jpg

我是写死的




写死了也没有关系可以发给我看看

你研究下几个模板的recom开头的lbi有现成的代码可以用

可以先在本地调试

学习了 都是高人啊

多多。。。

模板支持首页显示分类列表吗?进模板管理看看

ECSHOP学习资料:http://www.phpally.com

:):):)