diff --git a/blocktopmenu.php b/blocktopmenu.php
index 1230a04..1a1dba9 100644
--- a/blocktopmenu.php
+++ b/blocktopmenu.php
@@ -89,7 +89,7 @@ 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_SHOW_SUBMENU', '1'))
return false;
return true;
@@ -123,7 +123,7 @@ 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_SHOW_SUBMENU'))
return false;
return true;
@@ -182,6 +182,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_SHOW_SUBMENU', (bool)Tools::getValue('showsubmenu'), false, (int)$shop_group_id, (int)$shop_id);
if (!$updated)
{
@@ -612,32 +613,37 @@ private 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']))
- {
- $html .= '
';
- $html .= $this->generateCategoriesMenu($category['children'], 1);
-
- if ((int)$category['level_depth'] > 1 && !$is_children)
+
+ $shop_id = (int)$this->context->shop->id;
+ $shop_group_id = Shop::getGroupFromShop($shop_id);
+ if(Configuration::get('MOD_BLOCKTOPMENU_SHOW_SUBMENU', null, $shop_group_id, $shop_id)) {
+ if (isset($category['children']) && !empty($category['children']))
{
- $files = scandir(_PS_CAT_IMG_DIR_);
+ $html .= '';
+ $html .= $this->generateCategoriesMenu($category['children'], 1);
- if (count($files) > 0)
+ if ((int)$category['level_depth'] > 1 && !$is_children)
{
- $html .= '- ';
+ $files = scandir(_PS_CAT_IMG_DIR_);
+
+ if (count($files) > 0)
+ {
+ $html .= '
- ';
- foreach ($files as $file)
- if (preg_match('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $file) === 1)
- $html .= '';
+ foreach ($files as $file)
+ if (preg_match('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $file) === 1)
+ $html .= '';
- $html .= '
';
+ $html .= '';
+ }
}
- }
- $html .= '
';
+ $html .= '
';
+ }
}
-
+
$html .= '';
}
@@ -725,6 +731,7 @@ public function hookDisplayTop($param)
$shop_group_id = Shop::getGroupFromShop($shop_id);
$this->smarty->assign('MENU_SEARCH', Configuration::get('MOD_BLOCKTOPMENU_SEARCH', null, $shop_group_id, $shop_id));
+ $this->smarty->assign('MENU_SHOWSUBMENU', Configuration::get('MOD_BLOCKTOPMENU_SHOW_SUBMENU', null, $shop_group_id, $shop_id));
$this->smarty->assign('MENU', $this->_menu);
$this->smarty->assign('this_path', $this->_path);
}
@@ -953,6 +960,24 @@ public function renderForm()
'label' => $this->l('Disabled')
)
),
+ ),
+ array(
+ 'type' => 'switch',
+ 'label' => $this->l('Show Menu Children'),
+ 'name' => 'showsubmenu',
+ 'is_bool' => true,
+ 'values' => array(
+ array(
+ 'id' => 'active_on',
+ 'value' => 1,
+ 'label' => $this->l('Enabled')
+ ),
+ array(
+ 'id' => 'active_off',
+ 'value' => 0,
+ 'label' => $this->l('Disabled')
+ )
+ ),
)
),
'submit' => array(
@@ -989,6 +1014,26 @@ public function renderForm()
),
)
),
+ 'input' => array(
+ array(
+ 'type' => 'switch',
+ 'label' => $this->l('Show Children Menu'),
+ 'name' => 'showsubmenu',
+ 'is_bool' => true,
+ 'values' => array(
+ array(
+ 'id' => 'active_on',
+ 'value' => 1,
+ 'label' => $this->l('Enabled')
+ ),
+ array(
+ 'id' => 'active_off',
+ 'value' => 0,
+ 'label' => $this->l('Disabled')
+ )
+ ),
+ )
+ ),
'submit' => array(
'name' => 'submitBlocktopmenu',
'title' => $this->l('Save')
@@ -1232,16 +1277,19 @@ public function getConfigFieldsValues()
{
$shops = Shop::getContextListShopID();
$is_search_on = true;
+ $is_showsubmenu_on = true;
foreach ($shops as $shop_id)
{
- $shop_group_id = Shop::getGroupFromShop($shop_id);
- $is_search_on &= (bool)Configuration::get('MOD_BLOCKTOPMENU_SEARCH', null, $shop_group_id, $shop_id);
+ $shop_group_id = Shop::getGroupFromShop($shop_id);
+ $is_search_on &= (bool)Configuration::get('MOD_BLOCKTOPMENU_SEARCH', null, $shop_group_id, $shop_id);
+ $is_showsubmenu_on &= (bool)Configuration::get('MOD_BLOCKTOPMENU_SHOW_SUBMENU', null, $shop_group_id, $shop_id);
}
return array(
- 'search' => (int)$is_search_on
+ 'search' => (int)$is_search_on,
+ 'showsubmenu' => (int)$is_showsubmenu_on
);
}