diff --git a/blocktopmenu.php b/blocktopmenu.php index a9c0fce..caf83ff 100644 --- a/blocktopmenu.php +++ b/blocktopmenu.php @@ -91,7 +91,11 @@ public function install($delete_params = true) $this->clearMenuCache(); if ($delete_params) { - if (!$this->installDb() || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_ITEMS', 'CAT3,CAT26') || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_SEARCH', '1')) { + if (!$this->installDb() + || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_ITEMS', 'CAT3,CAT26') + || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_SEARCH', '1') + || !Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_DEPTH_LEVEL', '3') + ) { return false; } } @@ -128,7 +132,11 @@ public function uninstall($delete_params = true) $this->clearMenuCache(); if ($delete_params) { - if (!$this->uninstallDB() || !Configuration::deleteByName('MOD_BLOCKTOPMENU_ITEMS') || !Configuration::deleteByName('MOD_BLOCKTOPMENU_SEARCH')) { + if (!$this->uninstallDB() + || !Configuration::deleteByName('MOD_BLOCKTOPMENU_ITEMS') + || !Configuration::deleteByName('MOD_BLOCKTOPMENU_SEARCH') + || !Configuration::deleteByName('MOD_BLOCKTOPMENU_DEPTH_LEVEL') + ) { return false; } } @@ -189,6 +197,7 @@ public function getContent() } $updated &= Configuration::updateValue('MOD_BLOCKTOPMENU_SEARCH', (bool)Tools::getValue('search'), false, (int)$shop_group_id, (int)$shop_id); + $updated &= Configuration::updateValue('MOD_BLOCKTOPMENU_DEPTH_LEVEL', (int)Tools::getValue('depth_level'), false, (int)$shop_group_id, (int)$shop_id); if (!$updated) { $shop = new Shop($shop_id); @@ -592,6 +601,10 @@ protected function generateCategoriesOption($categories, $items_to_skip = null) protected function generateCategoriesMenu($categories, $is_children = 0) { + $shop_id = (int)$this->context->shop->id; + $shop_group_id = Shop::getGroupFromShop($shop_id); + $depthLevel = (int)Configuration::get('MOD_BLOCKTOPMENU_DEPTH_LEVEL', null, $shop_group_id, $shop_id); + $html = ''; foreach ($categories as $key => $category) { @@ -611,7 +624,7 @@ protected function generateCategoriesMenu($categories, $is_children = 0) && (int)Tools::getValue('id_category') == (int)$category['id_category']) ? ' class="sfHoverForce"' : '').'>'; $html .= ''.$category['name'].''; - if (isset($category['children']) && !empty($category['children'])) { + if (isset($category['children']) && !empty($category['children']) && $category['level_depth'] <= $depthLevel) { $html .= '