Skip to content

Manage a single menu instance with different templates for Desktop and Mobile#402

Open
MaximSR wants to merge 5 commits intoSnowdogApps:developfrom
studioraz:enhahcenemt/SRP-1360-manage-a-single-menu-instance-with-different-templates-for-Desktop-and-Mobile
Open

Manage a single menu instance with different templates for Desktop and Mobile#402
MaximSR wants to merge 5 commits intoSnowdogApps:developfrom
studioraz:enhahcenemt/SRP-1360-manage-a-single-menu-instance-with-different-templates-for-Desktop-and-Mobile

Conversation

@MaximSR
Copy link
Copy Markdown

@MaximSR MaximSR commented Mar 30, 2026

Problem

The Hyva theme uses two separate menu identifiers for desktop and mobile navigation: hyva-topmenu-desktop and hyva-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-identifier argument for the menu block and ensures backward compatibility.

The key changes are:

  1. Block/Menu.php:

    • The getMenuTemplate method is updated to prioritize the new template-identifier argument for template resolution.
    • If the template-identifier is not set, the block falls back to using the menu argument to find the template. This maintains full backward compatibility for existing menu block implementations.
  2. view/frontend/layout/default_hyva.xml:

    • The topmenu-mobile can use hyva-topmenu-desktop as its data source on demand (via the menu argument).
    • Its presentation is sourced from the hyva-topmenu-mobile template (via the template-identifier argument).
    • This allows administrators to manage the menu content in a single place (hyva-topmenu-desktop) while still having distinct layouts for desktop and mobile.

@MaximSR MaximSR changed the title Enhahcenemt/srp 1360 manage a single menu instance with different templates for desktop and mobile Manage a single menu instance with different templates for Desktop and Mobile Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants