我想在opencart的标题菜单中添加多级下拉菜单。我目前使用的是模板,而不是默认的opencart模板。我无法在控制器文件中找到$ categories_tm以添加第三级下拉列表。
这是我的header.tlp代码,用于显示标题类别菜单
<?php if ($categories) { ?>
<div class="container">
<div id="menu-gadget" class="menu-gadget">
<div id="menu-icon" class="menu-icon"><?php echo $text_category; ?></div>
<?php if ($categories_tm) { echo $categories_tm; } ?>
</div>
</div>
<script type="text/javascript">
jQuery(window).load(function () {
if ($('body').width() > 767) {
$('#tm_menu').TMStickUp({})
}});
</script>
<div id="tm_menu" class="nav__primary">
<div class="container">
<?php if ($categories_tm) { echo $categories_tm; } ?>
<div class="clear"></div>
</div>
</div>
<?php } ?>
这是我的控制器文件header.php
foreach ($categories as $category) {
if ($category['top']) {
// Level 2
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
$filter_data = array(
'filter_category_id' => $child['category_id'],
'filter_sub_category' => true
);
$children_data[] = array(
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
// Level 1
$data['categories'][] = array(
'name' => $category['name'],
'children' => $children_data,
'column' => $category['column'] ? $category['column'] : 1,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
}