鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > cms安装教程 > ecshopcms > >

首页调用指定分类下子分类方法

来源:互联网 作者:佚名 时间:2015-01-06 13:41
模板首页一般都有分楼层显示的分类商品,每个楼层右上角会有该分类下小分类排列显示的: function get_parent_id_tree($parent_id) { $three_c_arr = array(); $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']-table('category') . WHERE parent_id = '$p

  模板首页一般都有分楼层显示的分类商品,,每个楼层右上角会有该分类下小分类排列显示的:

 

 

  function get_parent_id_tree($parent_id)
{
$three_c_arr = array();
$sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '$parent_id' AND is_show = 1 ";
if ($GLOBALS['db']->getOne($sql))
{
$child_sql = 'SELECT cat_id, cat_name, parent_id, is_show ' .
'FROM ' . $GLOBALS['ecs']->table('category') .
"WHERE parent_id = '$parent_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC ";
$res = $GLOBALS['db']->getAll($child_sql);
foreach ($res AS $row)
{
if ($row['is_show'])
$three_c_arr[$row['cat_id']]['id']   = $row['cat_id'];
$three_c_arr[$row['cat_id']]['name'] = $row['cat_name'];
$three_c_arr[$row['cat_id']]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']);
}
}
return $three_c_arr;
}

 

 

   

   <?php
 $this->assign('thiscid1', get_parent_id_tree(17));//
调用父级分类的下级分类
 ?>

 

   <!--{foreach from=$thiscid1 item=list name=name}-->
 <A href="{$list.url}" target=_blank >{$list.name}</A>
  <!--{/foreach}-->

 

 

网友评论
<