opencart 默认只有二级导航 修改下代码让他展示三级导航
在2.3.0.2版本下测试
catalog\controller\common\header.php
在$children_data[] = array 下面添加
'children3' => $data['child3'],
上面再添加
$children3_data = array();
$data['child3'] = array();
$children3 = $this->model_catalog_category->getCategories($child['category_id']);
foreach ($children3 as $child3) {
$data['child3'][] = array(
'name' => $child3['name'],
'href' => $this->url->link('product/category', 'path=' . $child3['category_id'])
);
}
URL 的ID自己定义
然后模板里 catalog\view\theme\模板名\template\common\header.tpl
在<li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li>下面添加
<?php if($child['children3']){?>
<ul>
<?php foreach ($child['children3'] as $child3) { ?>
<li><a href="<?php echo $child3['href']; ?>"><?php echo $child3['name']; ?></a></li>
<?php } ?>
</ul>
<?php } ?>
这样就完成了