Skip to content

Add hook actionMainMenuModifier#70

Merged
boherm merged 1 commit intoPrestaShop:devfrom
bibips:add-hook-displaymainmenu
Apr 28, 2025
Merged

Add hook actionMainMenuModifier#70
boherm merged 1 commit intoPrestaShop:devfrom
bibips:add-hook-displaymainmenu

Conversation

@bibips
Copy link
Copy Markdown
Contributor

@bibips bibips commented Jun 5, 2023

Questions Answers
Description? Allow main menu to be extended by other modules thanks a new hook actionMainMenuModifier.
Thanks this hook it's possible to have menu items specific per customer by example.
Type? improvement
BC breaks? no
Deprecations? no
Fixed ticket? No issue
How to test? Register hook actionMainMenuModifier and add or edit something into main menu

Hook usage :

    public function hookActionMainMenuModifier(array $hookParams)
    {
          $hookParams['menu']['children'][] = [
              'type' => 'link',
              'label' => $this->trans('Test', [], 'Modules.Test.Menu'),
              'url' => $this->context->link->getModuleLink($this->name, 'pickup'),
              'depth' => 1,
              'children' => [],
              'open_in_new_window' => "0",
              'page_identifier' => $this->trans('Test', [], 'Modules.Test.Menu'),
              'current' => false
          ];
    }

@bibips bibips force-pushed the add-hook-displaymainmenu branch 2 times, most recently from 8d39ed6 to e2c52e5 Compare June 7, 2023 12:58
M0rgan01
M0rgan01 previously approved these changes Jun 19, 2023
@Hlavtox
Copy link
Copy Markdown
Contributor

Hlavtox commented Jun 19, 2023

Wouldn't it be better if you could change the $menu variable instead? With this solution, you can display things only after the list, but cannot modify the items.

@bibips
Copy link
Copy Markdown
Contributor Author

bibips commented Jun 19, 2023

Wouldn't it be better if you could change the $menu variable instead? With this solution, you can display things only after the list, but cannot modify the items.

I like this Idea

@bibips bibips force-pushed the add-hook-displaymainmenu branch from e2c52e5 to b0601c8 Compare June 19, 2023 11:35
@bibips bibips changed the title Add hook displayMainMenu Add hook actionMainMenuModifier Jun 19, 2023
@bibips bibips requested a review from M0rgan01 July 11, 2023 11:52
@bibips
Copy link
Copy Markdown
Contributor Author

bibips commented Oct 16, 2023

@Hlavtox @M0rgan01 any updates for this PR ?

@M0rgan01
Copy link
Copy Markdown

Sorry, I lost the thread! Yes it's ok for me :) You will need to add the new hook on the core side (in hook.xml file)

M0rgan01
M0rgan01 previously approved these changes Oct 16, 2023
@Hlavtox
Copy link
Copy Markdown
Contributor

Hlavtox commented Oct 16, 2023

@M0rgan01 I think we shouldn't, the core should include no data or references to any modules I think.

@M0rgan01
Copy link
Copy Markdown

I thought that was the case :) Everything is good

@AureRita AureRita self-assigned this Oct 18, 2023
@AureRita
Copy link
Copy Markdown

AureRita commented Oct 18, 2023

Hi @bibips

Thank you for your PR, I tested it and unfortunately this one doesn't works as expected as you can see :

image

Indeed, the "use Hook;" doesn't seems to works and, because of that, the hook isn't accessible

image

Thank you

@bibips
Copy link
Copy Markdown
Contributor Author

bibips commented May 31, 2024

@AureRita Excuse me for the delay, I've removed use Hook; as suggested

boherm
boherm previously approved these changes Jun 12, 2024
@jtraulle
Copy link
Copy Markdown

This would be a great addition for external modules to be able to add links to the main menu.
Anything missing here @AureRita for this to be merged ?

Copy link
Copy Markdown
Contributor

@Hlavtox Hlavtox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see much value in this… isn't the sole purpose of menu that it's purely configurable by people?

Do you have any real use case for this hook?

jolelievre
jolelievre previously approved these changes Mar 3, 2025
Copy link
Copy Markdown

@jolelievre jolelievre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bibips

@jolelievre jolelievre dismissed Hlavtox’s stale review March 3, 2025 09:40

The explained use case makes sense to me and there are probably many others. The implementation is also ok so I dismiss your blocker for now @Hlavtox.
If you are other worries don't hesitate to re-review

@paulnoelcholot
Copy link
Copy Markdown

Hello @bibips,

I tried to test your PR, but I'm not sure I understood the steps to reproduce correctly. Can you please explain the steps to reproduce more precisely?

Thanks for your feedback!

@bibips
Copy link
Copy Markdown
Contributor Author

bibips commented Mar 23, 2025

@paulnoelcholot I have created a module that use this new hook for your test. Thanks this module you can see a new menu item only if a customer is connected.
actionmainmenumodifier.zip

Copy link
Copy Markdown
Contributor

@Hlavtox Hlavtox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to change config.xml if you are bumping version.

Thanks this hook it's possible to alter main menu. For instance you can
display menu items per customer or per group of customer
@bibips bibips dismissed stale reviews from jolelievre and boherm via ff78da0 March 24, 2025 07:45
@bibips bibips force-pushed the add-hook-displaymainmenu branch from f775adb to ff78da0 Compare March 24, 2025 07:45
@bibips
Copy link
Copy Markdown
Contributor Author

bibips commented Mar 24, 2025

@Hlavtox It's fixed

@paulnoelcholot
Copy link
Copy Markdown

Hello @bibips,

I tested your PR and it's good for me!

Thanks!

image

@paulnoelcholot paulnoelcholot added QA ✔️ Status: Check done, Code approved and removed waiting for QA labels Apr 28, 2025
@boherm boherm merged commit 173ea0d into PrestaShop:dev Apr 28, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from Ready for review to Merged in PR Dashboard Apr 28, 2025
@ps-jarvis
Copy link
Copy Markdown

PR merged, well done!

Message to @PrestaShop/committers: do not forget to milestone it before the merge.

@boherm
Copy link
Copy Markdown
Member

boherm commented Apr 28, 2025

Thanks @bibips!

@boherm boherm added this to the 2.3.5 milestone Apr 28, 2025
@nicosomb nicosomb mentioned this pull request Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hook Contribution QA ✔️ Status: Check done, Code approved

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

10 participants