Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hook actionMainMenuModifier #70

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions ps_mainmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct()
{
$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;

Expand Down Expand Up @@ -136,7 +136,10 @@ public function installDb()
`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)
Expand Down Expand Up @@ -1489,8 +1492,12 @@ public function getWidgetVariables($hookName, array $configuration)

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');
Expand Down
28 changes: 28 additions & 0 deletions upgrade/upgrade-2.3.5.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @author PrestaShop SA <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}

function upgrade_module_2_3_5($module)
{
return 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')");
}