Php Opencart类别模块>;显示第二个孩子
我一直在努力实现在边栏分类模块中显示分类的第二个子项,如下所示 例如:Php Opencart类别模块>;显示第二个孩子,php,oop,filtering,opencart,Php,Oop,Filtering,Opencart,我一直在努力实现在边栏分类模块中显示分类的第二个子项,如下所示 例如:玩具>男孩>遥控车 现在有这个 <ul> <?php foreach ($categories as $category) { ?> <?php if ($category['category_id'] == $category_id) { ?> <li class="cat-active"> <a href="<?php ec
玩具>男孩>遥控车
现在有这个
<ul>
<?php foreach ($categories as $category) { ?>
<?php if ($category['category_id'] == $category_id) { ?>
<li class="cat-active">
<a href="<?php echo $category['href']; ?>" class="active"><?php echo $category['name']; ?></a>
<?php } else { ?>
<li>
<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
<?php } ?>
<?php if ($category['children']) { ?>
<b class="cc"></b>
<ul class="col-subcat">
<?php foreach ($category['children'] as $child) { ?>
<li>
<?php if ($child['category_id'] == $child_id) { ?>
<a href="<?php echo $child['href']; ?>" class="active"><?php echo $child['name']; ?></a>
<?php } else { ?>
<a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a>
<?php } ?>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
</ul>
-
-
-
只显示
玩具>男孩
我不知道如何显示第二个孩子(“玩具>男孩>RC汽车”)
对于建议,您必须自定义2个文件。
$children_data_2=array();
$children\u 2=$this->model\u catalog\u category->getCategories($child['category\u id');
foreach($children_2作为$children_2){
$filter\u data=数组(
'filter_category_id'=>$child_2['category_id'],
“筛选子类别”=>true
);
$children_data_2[]=数组(
'category_id'=>$child_2['category_id'],
'name'=>$child_2['name']。($this->config->get('config_product_count')?'('.$this->model_catalog_product->getTotalProducts('filter_data'):''),
'href'=>$this->url->link('product/category','path='.$category['category\u id'..''.$child['category\u id'..'.'.$child\u 2['category\u id'.]
);
}
你想做一些递归吗?每次你再深入一层,你都必须抛出一个新的- 然后一个
- 循环检查这个,我想同样的,请在询问之前做一个适当的搜索(使用例如谷歌)。你的问题已经在这里得到了回答(互联网上有很多实现同样目的的教程)。