Skip to main content
added 40 characters in body
Source Link
MrD
  • 6.3k
  • 4
  • 28
  • 37

May you can use hooks:

/**

  • Implements hook_preprocess_HOOK() for menu.html.twig. */ function mytheme_preprocess_menu(&$variables) { if ($variables['menu_name'] == 'main') { if (!isset($variables['attributes']['class'])) { $variables['attributes']['class'] = []; } $variables['attributes']['class'] = array_merge($variables['attributes']['class'], ['my-main-menu']); } }
/** * Implements hook_preprocess_HOOK() for menu.html.twig. */ function mytheme_preprocess_menu(&$variables) { if ($variables['menu_name'] == 'main') { if (!isset($variables['attributes']['class'])) { $variables['attributes']['class'] = []; } $variables['attributes']['class'] = array_merge($variables['attributes']['class'], ['my-main-menu']); } } 

Source: https://www.drupal.org/docs/8/theming-drupal-8/modifying-attributes-in-a-theme-file

May you can use hooks:

/**

  • Implements hook_preprocess_HOOK() for menu.html.twig. */ function mytheme_preprocess_menu(&$variables) { if ($variables['menu_name'] == 'main') { if (!isset($variables['attributes']['class'])) { $variables['attributes']['class'] = []; } $variables['attributes']['class'] = array_merge($variables['attributes']['class'], ['my-main-menu']); } }

Source: https://www.drupal.org/docs/8/theming-drupal-8/modifying-attributes-in-a-theme-file

May you can use hooks:

/** * Implements hook_preprocess_HOOK() for menu.html.twig. */ function mytheme_preprocess_menu(&$variables) { if ($variables['menu_name'] == 'main') { if (!isset($variables['attributes']['class'])) { $variables['attributes']['class'] = []; } $variables['attributes']['class'] = array_merge($variables['attributes']['class'], ['my-main-menu']); } } 

Source: https://www.drupal.org/docs/8/theming-drupal-8/modifying-attributes-in-a-theme-file

Source Link

May you can use hooks:

/**

  • Implements hook_preprocess_HOOK() for menu.html.twig. */ function mytheme_preprocess_menu(&$variables) { if ($variables['menu_name'] == 'main') { if (!isset($variables['attributes']['class'])) { $variables['attributes']['class'] = []; } $variables['attributes']['class'] = array_merge($variables['attributes']['class'], ['my-main-menu']); } }

Source: https://www.drupal.org/docs/8/theming-drupal-8/modifying-attributes-in-a-theme-file