如何改变首页产品分类树的路径

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

。。。说的太模糊

回答:
简单撒~~这数据要么是 index.php 里的 要么是 index.dwt 里的 ~~搜索 category.php?id= 就可以了撒~~

说的不错。不知道对不对

如果在模板里面找不到相应代码就是在lib_common.php文件里面的build_uri函数处理

  1. function get_categories_tree($cat_id = 0)
  2. {
  3. if ($cat_id > 0)
  4. {
  5. $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '$cat_id'";
  6. $parent_id = $GLOBALS['db']->getOne($sql);
  7. }
  8. else
  9. {
  10. $parent_id = 0;
  11. }

  12. /*
  13. 判断当前分类中全是是否是底级分类,
  14. 如果是取出底级分类上级分类,
  15. 如果不是取当前分类及其下的子分类
  16. */
  17. $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '$cat_id' AND is_show = 1 ";
  18. if ($GLOBALS['db']->getOne($sql) || $parent_id == 0)
  19. {
  20. /* 获取当前分类及其子分类 */
  21. $sql = 'SELECT a.cat_id, a.cat_name, a.sort_order AS parent_order, a.cat_id, a.is_show,' .
  22. 'b.cat_id AS child_id, b.cat_name AS child_name, b.sort_order AS child_order ' .
  23. 'FROM ' . $GLOBALS['ecs']->table('category') . ' AS a ' .
  24. 'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS b ON b.parent_id = a.cat_id AND b.is_show = 1 ' .
  25. "WHERE a.parent_id = '$parent_id' ORDER BY parent_order ASC, a.cat_id ASC, child_order ASC";
  26. }
  27. else
  28. {
  29. /* 获取当前分类及其父分类 */
  30. $sql = 'SELECT a.cat_id, a.cat_name, b.cat_id AS child_id, b.cat_name AS child_name, b.sort_order, b.is_show ' .
  31. 'FROM ' . $GLOBALS['ecs']->table('category') . ' AS a ' .
  32. 'LEFT JOIN ' . $GLOBALS['ecs']->table('category') . ' AS b ON b.parent_id = a.cat_id AND b.is_show = 1 ' .
  33. "WHERE b.parent_id = '$parent_id' ORDER BY sort_order ASC";
  34. }
  35. $res = $GLOBALS['db']->getAll($sql);

  36. $cat_arr = array();
  37. foreach ($res AS $row)
  38. {
  39. if ($row['is_show'])
  40. {
  41. $cat_arr[$row['cat_id']]['id'] = $row['cat_id'];
  42. $cat_arr[$row['cat_id']]['name'] = $row['cat_name'];
  43. $cat_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);

  44. if ($row['child_id'] != NULL)
  45. {
  46. $cat_arr[$row['cat_id']]['children'][$row['child_id']]['id'] = $row['child_id'];
  47. $cat_arr[$row['cat_id']]['children'][$row['child_id']]['name'] = $row['child_name'];
  48. $cat_arr[$row['cat_id']]['children'][$row['child_id']]['url'] = build_uri('category', array('cid' => $row['child_id']), $row['child_name']);
  49. }
  50. }
  51. }

  52. return $cat_arr;
  53. }
复制代码



$cat_arr[$row['cat_id']]['children'][$row['child_id']]['url'] = build_uri('category', array('cid' => $row['child_id']), $row['child_name']);