Problem/Motivation

People might want to render one menu with different markups. That might be necessary in scenarios where there is different styling for menu in mobile and desktop version. There is no theme suggestions to do this and it I didn't find way to add these suggestions in the theme_suggestions_alter so this is not achievable for themers.

Proposed resolution

If menu is rendered in a block create theme suggestions for a menu based on block.

Remaining tasks

-

User interface changes

-

API changes

-

Comments

lauriii’s picture

Title: Specific menu templates per block » Specific menu theme suggestions based on block
LewisNyman’s picture

Is this issue to make it possible to add template suggestions or to add template suggestions?

lauriii’s picture

I guess we need to do both to make it happen. I think we should have the theme suggestions there out-of-the-box because I'm pretty sure people are willing to theme their themes per block basis because now they have the possibility to print the block for multiple times.

Cottser’s picture

Sorry for the vague comment but I think blocks (or at least at the point of suggestion hooks, preprocess, etc.) are not aware of their instance in D8, so I have my doubts right now that this is technically feasible. Or in other words that a menu being printed in a block would have any better change of getting this information.

Don't let this hold you back but just a warning.

hass’s picture

We need menu suggestions also with regions. Regions are most important as style of a menu may need to change per region. I had this requirement very very often and core is not flexible to solve this. Please also add region suggestion.

Cottser’s picture

@hass I don't see that happening. See https://www.drupal.org/node/2011434

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.