Add hook actionMainMenuModifier

Thanks this hook it's possible to alter main menu. For instance you can
display menu items per customer or per group of customer
This commit is contained in:
bibips
2023-06-03 23:05:41 +02:00
parent d49c1d1035
commit ff78da047e
3 changed files with 39 additions and 4 deletions
+10 -3
View File
@@ -69,7 +69,7 @@ class Ps_MainMenu extends Module implements WidgetInterface
{
$this->name = 'ps_mainmenu';
$this->tab = 'front_office_features';
$this->version = '2.3.4';
$this->version = '2.3.5';
$this->author = 'PrestaShop';
$this->imageFiles = null;
@@ -136,7 +136,10 @@ class Ps_MainMenu extends Module implements WidgetInterface
`label` VARCHAR( 128 ) NOT NULL ,
`link` VARCHAR( 128 ) NOT NULL ,
INDEX ( `id_linksmenutop` , `id_lang`, `id_shop`)
) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8mb4;');
) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8mb4;') &&
Db::getInstance()->execute('
INSERT IGNORE INTO `' . _DB_PREFIX_ . 'hook` (`name`, `title`, `description`) VALUES
(\'actionMainMenuModifier\', \'Modify main menu view data\', \'This hook allows to alter main menu data\');');
}
public function uninstall($delete_params = true)
@@ -1489,8 +1492,12 @@ class Ps_MainMenu extends Module implements WidgetInterface
public function renderWidget($hookName, array $configuration)
{
$menu = $this->getWidgetVariables($hookName, $configuration);
Hook::exec('actionMainMenuModifier', ['menu' => &$menu]);
$this->smarty->assign([
'menu' => $this->getWidgetVariables($hookName, $configuration),
'menu' => $menu,
]);
return $this->fetch('module:ps_mainmenu/ps_mainmenu.tpl');