最新消息: 新版网站上线了!!!

Ecshop调用指定分类下隐藏分类

1.打开您的文件根目录下 includes/lib_goods.php 文件,在最后一行加入一个方法:
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 = 0 ";
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 = 0 ORDER BY sort_order ASC, cat_id ASC ";
$res = $GLOBALS['db']->getAll($child_sql);
foreach ($res AS $row)
{
if ($row['is_show'] == 0)
$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;
}
 
2、首页头部调用
<!--{foreach from=get_categories_tree(0) item=cat name=cat0}--> 
{if $smarty.foreach.cat0.iteration < 7}
(以上是最大的分类)
 
<?php
$GLOBALS['smarty']->assign('child_partent',get_parent_id_tree($GLOBALS['smarty']->_var['cat']['id']));
 ?>
    <!--{foreach from=$child_partent item=child12 name=name13}--> 
  {if $smarty.foreach.name13.iteration < 4}
    <a href="{$child12.url}" target="_blank" title="{$child12.name}">{$child12.name}</a>&nbsp;
{/if}
    <!--{/foreach}-->

转载请注明:谷谷点程序 » Ecshop调用指定分类下隐藏分类