Repository navigation
Fix duplicated menu with changed identifier throws an error if same submenu template does not exist - #416
Open
manan-patel1 wants to merge 2 commits into
Open
Fix duplicated menu with changed identifier throws an error if same submenu template does not exist#416manan-patel1 wants to merge 2 commits into
manan-patel1 wants to merge 2 commits into
Conversation
…ubmenu template does not exist
jupiterlewis
suggested changes
Sep 17, 2026
|
|
||
| if ($submenuTemplate) { | ||
| $customSubmenuTemplate = 'Snowdog_Menu::' . $this->getMenu()->getIdentifier() . "/menu/custom/sub_menu/{$submenuTemplate}.phtml"; | ||
| $submenuTemplate = $this->templateResolver->isValidTemplate($block, $customSubmenuTemplate) |
There was a problem hiding this comment.
@manan-patel1 isValidTemplate does a filesystem call. Since this is running for every submenu item, the validity should be cached. Take a look at Model/TemplateResolver.php getMenuTemplate(). Check if you can use that instead.
jupiterlewis
approved these changes
Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes an issue where a duplicated menu can break the frontend when its configured submenu template does not exist for the new menu identifier.
This issue was originally reported in #379 and later reproduced with an
Invalid template fileexception in #391.Previous Approach
The initial fix was proposed in PR #393.
The previous implementation added Hyva-specific template validation to
Block/Menu.php. SinceBlock/Menu.phpis shared across themes and should remain theme-agnostic, this approach was not suitable.Changes
isValidTemplate()method toTemplateResolver.phpto validate whether a template is available and valid within the current theme/module layout framework.Menu.phpto validate the custom submenu template before using it.Block/Menu.phptheme-agnostic without introducing Hyva-specific logic.How the Fix Solves It
When a menu is duplicated and its identifier is changed, the copied submenu template may no longer exist for the new identifier.
The custom submenu template is now validated before it is assigned:
isValidTemplate()checks whether the template is available and valid.This prevents an invalid submenu template from breaking the frontend while preserving the existing submenu template configuration.
How to Test
hyva-topmenu-desktop.3-levelsubmenu template, ensuring that it is specific tohyva-topmenu-desktop.hyva-topmenu-mobile.Expected Result
The frontend should render the menu using the default submenu template instead of throwing an
Invalid template fileexception.Related Issues / PRs