OpenCart: 3й уровень меню категорий товаров OpenCart 2x-2.2
- 18 октября, 2022
- 1:13 пп
- Нет комментариев
в \catalog\controller\common\header.php
меняем это:
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'])
);
}
на это
foreach ($children as $child) {
$children_data2 = array();
$children2 = $this->model_catalog_category->getCategories($child['category_id']);
foreach ($children2 as $child2) {
$children_data2[] = array(
'name' => $child2['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $child['category_id'] . '_' . $child2['category_id']),
);
}
$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']),
'children' => $children_data2,
);
}
далее
в шаблоне header.tpl
это
на это
а в файл стилей stylesheet.css добавим
.child {
display:none;
}
#menu .dropdown-inner ul > li:hover .child {
display:block;
background: #fff;
border: 1px solid #ddd;
left: 100%;position: absolute;
top: 0;z-index: 9;
}
nav#menu.navbar ul li div.dropdown-menu div ul li {
position:relative;
}