Manage a single menu instance with different templates for Desktop and Mobile#402
Open
MaximSR wants to merge 5 commits intoSnowdogApps:developfrom
Conversation
…e for menu items and different templates
…e for menu items and different templates
…e for menu items and different templates
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.
Problem
The Hyva theme uses two separate menu identifiers for desktop and mobile navigation:
hyva-topmenu-desktopandhyva-topmenu-mobile. This requires administrators to configure and maintain two separate menus, even if the content is identical. This leads to duplicated effort and potential inconsistencies between the desktop and mobile menus.Solution
This pull request refactors the menu block to decouple the menu's data source from its rendering template. This allows developers to use one menu as a data source while rendering it with a template from another menu identifier.
The solution introduces a new
template-identifierargument for the menu block and ensures backward compatibility.The key changes are:
Block/Menu.php:getMenuTemplatemethod is updated to prioritize the newtemplate-identifierargument for template resolution.template-identifieris not set, the block falls back to using themenuargument to find the template. This maintains full backward compatibility for existing menu block implementations.view/frontend/layout/default_hyva.xml:topmenu-mobilecan usehyva-topmenu-desktopas its data source on demand (via themenuargument).hyva-topmenu-mobiletemplate (via thetemplate-identifierargument).hyva-topmenu-desktop) while still having distinct layouts for desktop and mobile.