Last active
June 16, 2017 07:46
-
-
Save iledcom/834c41b7c37a589b0409c69fbaa16d9d to your computer and use it in GitHub Desktop.
Категории третьего уровня в OpenCart2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Меняем в файле /home/ohranactr/public_html/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) { | |
$filter_data = array(); | |
$filter_data2 = array(); | |
$children_data2 = array(); | |
$children2 = $this->model_catalog_category->getCategories($child['category_id']); | |
foreach ($children2 as $child2) { | |
$filter_data2 = array( | |
'filter_category_id' => $child2['category_id'], | |
'filter_sub_category' => true | |
); | |
$children_data2[] = array( | |
'name' => $child2['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data2) . ')' : ''), | |
'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, | |
); | |
} | |
В файле /home/ohranactr/public_html/catalog/view/theme/MyTheme/template/common/header.tpl | |
это: | |
<?php foreach ($children as $child) { ?> | |
<li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li> | |
<?php } ?> | |
на это: | |
<?php foreach ($children as $child) { ?> | |
<li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a> | |
<?php if ($child['children']) {?> | |
<div class="child"><ul class="list-unstyled"> | |
<?php foreach ($child['children'] as $child) { ?> | |
<li><a href="<?php echo $child['href']; ?>"><?php echo $child['name']; ?></a></li> | |
<?php } ?> | |
</ul></div> | |
<?php } ?> | |
</li> | |
<?php } ?> | |
в файл стилей 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment