You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
So navbar class should be removed in the block template as the page.html.twig allows you to add multiple menus. Removing it in block--system-menu-block.html would break menu that are not rendered in page.main_navigation or page.second_navigation region.
Somethings like this would allow to have template suggestion depending of the region:
// Add a region variable to a block.
// http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion
function THEMENAME_preprocess_block(&$variables) {
if (isset($variables["elements"]["#id"])) {
$block_id = $variables["elements"]["#id"];
$block = \Drupal\block\Entity\Block::load($block_id);
if ($block) {
$variables["content"]["#attributes"]["region"] = $block->getRegion();
}
}
}
// add a template suggestion based on region name
// http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion
function THEMENAME_theme_suggestions_menu_alter(array &$suggestions, array $variables) {
if (isset($variables["attributes"]["region"])) {
$suggestions[] = $variables["theme_hook_original"] . "__" . $variables["attributes"]["region"];
}
}
Then we can use specific block template for menu in those region. Somethings like that:
{% set heading_id = attributes.id ~ '-menu'|clean_id %}
{# Label. If not displayed, we still provide it for screen readers. #}
{% if not configuration.label_display %}
{% set title_attributes = title_attributes.addClass('sr-only') %}
{% endif %}
<h2{{ title_attributes.setAttribute('id', heading_id) }}>{{ configuration.label }}</h2>
{% block content %}
{{ content }}
{% endblock %}
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Nav block added in navbar add again a uselss nav.
The problem is block--system-menu-block.html add the nav and page.html.twig also have a nav.
The text was updated successfully, but these errors were encountered: