Caching of sub site menus


We currently have a Drupal 8 site that has subsites (accessed via subdomains).

On the main site (non-subdomain) we have a main navigation menu defined (this is presenting correctly on the main site).

On each sub site we have a domain specific main navigation menu defined (these are presenting correctly on each subsite).

We have a footer menu that is used as a placeholder, defining only top level navigation items (no children). This footer menu is used both on the main site and each sub site.

The footer navigation child items are cloned from the main navigation (if on the main site, the child links are cloned from the main navigation as defined, if on a sub site, the child items are cloned from the sub site main navigation as defined). This is working.

We also do some clean up to remove top level footer items that arent present in the main/sub sites navigation menu.


If we clear the cache & load the main site, we get the expected footer items shown.

If we clear the cache & load a sub site, we get the expected footer items shown.

If we clear the cache & load the main site, and then load a sub site without clearing the cache again, we get the main sites footer items presented, not the desired sub sites footer items.

We have put in place caching directives for which we believe should be recognising that the sub site and main site have different url’s and should be caching these footer menu’s separately.


// Implements hook_rebuild().  function modulename_rebuild() {   Menu::load('main')->addCacheContexts(['']);   Menu::load('footer')->addCacheContexts(['']); }  // Implements hook_menu_local_tasks_alter().  function modulename_menu_local_tasks_alter(&$  data, $  route_name, &$  cacheability) {   $  cacheability->addCacheContexts(['']); }  // Implements hook_menu_links_discovered_alter().  function modulename_menu_links_discovered_alter(&$  links) {   $  subdomain = CustomDomainModule::getSubdomain();   $  menu_name = 'main';    if (!empty($  subdomain)) {     $  menu_name = 'main_navigation_' . $  subdomain;   }    $  parameters = \Drupal::menuTree()->getCurrentRouteMenuTreeParameters($  menu_name);   $  parameters->setMinDepth(0)->setMaxDepth(2)->onlyEnabledLinks();    $  navMenuItems = \Drupal::menuTree()->load($  menu_name, $  parameters);    // Get all top level links for the footer menu.   $  parameters->setMaxDepth(1);   $  footerMenuItems = \Drupal::menuTree()->load('footer', $  parameters);   $  count = 0;    // Enumerate links for the footer menu.   foreach ($  footerMenuItems as $  key => $  value) {     foreach ($  navMenuItems as $  item) {       // if we have found the matching parent       if ($  item->link->getTitle() === $  value->link->getTitle()) {         if ($  item->hasChildren) {           foreach ($  item->subtree as $  subItem) {             $  subItemLink = $  subItem->link;              $  link = [               'title' => $  subItemLink->getTitle(),               'description' => $  subItemLink->getDescription(),               'parent' => $  key,               'weight' => $  subItemLink->getWeight(),               'options' => $  subItemLink->getOptions(),             ];              // Get the route name from the original main nav.             $  originalLink = $  subItemLink->getUrlObject();              if ($  originalLink->isRouted()) {               // Add route properties if there was a route defined on the main nav.               $  link['route_name'] = $  originalLink->getRouteName();               $  link['route_parameters'] = $  originalLink->getRouteParameters();             } else {               $  link['url'] = $  originalLink->getUri();             }              $  id = $  key . '_alternate_' . $  count;             $  links[$  id] = $  link;              $  count++;           }         }       }     }   } } 

Using Layout Builder with Menus

I followed this tutorial but am having some issues. I enabled menu_link_extras and layout_builder on my site.

I enabled layout builder on my menu, added a menu link and added a block to that link’s layout. No matter what I do I can’t seem to get the blocks I’ve added in layout builder to show on the page. Is there something I’m missing in getting this to work correctly?

Thank you.

Could SER get a way to buffer the choices in the Category pull-down menus on target sites?

…because I’d like to translate them and learn the phrases that constitute the various categories in different languages.
If there was a way to save the choices, just so I can enter them into G! translate and make a cheat sheet I print out or have in a file so I can learn them, that would be very useful.
Hope all you guys and girls are having a fun weekend.  :)

Libreoffice has no menubar in Kubuntu 18.04 if Application button (for global menus) is added on window titlebar

It looks like a bug but I am not sure which program is to blame..

In Plasma 5.12 the option to add global menus in window titlebar has been removed. There is a panel widget that adds global menus to the panel, but also global menus are still available in the window titlebar as a button. I have added that button with global menus as indicated here. That’s under System Settings > Application Style > Windows Decorations > (tab) Buttons:

enter image description here

The idea is to get the global menus into a left-side button on the window upper margin; like for example in Chrome:

enter image description here

When this is done, Libreoffice has no menubar anymore. Adding the Menubar button and using it has no effect.

enter image description here

But once the “Application” button is dragged away from the titlebar at System Settings > Application Style > Windows Decorations > (tab) Buttons, the menubar in Libreoffice comes back.

enter image description here

Clear region with menu’s per url cache

I have a region with menus, a menus displays depending on the url example if on the about page(sitename/about-us), display about menu and links as a sub menu.

It works, but the problem is after navigating through the site a couple of times, the region caches. is the anyway i can clear the regions cache on page reload.

I tried the below in my .theme

/** * Implements hook_preprocess_HOOK() for block.html.twig. */ function themename_preprocess_block(&$ vars) { the menu block id name in the region if($ vars[‘derivative_plugin_id’] == ‘submenu’) { //– This stops the block being cache in drupal 8 $ vars[‘#cache’][‘max-age’] = 0;

} }

also tried

/** * Implements hook_preprocess_HOOK() for block.html.twig. */ function themename_preprocess_block(&$ vars) {

if($ vars[‘derivative_plugin_id’] == ‘theme-block-branding’) { //– This stops the block being cache in drupal 8 $ vars[‘#cache’][‘max-age’] = 0;

} }

not sure what steps I can follow to achieve the above

What is the significance of the three dots “…” on menus and buttons and how to use them right?

Adding three dots after the title of items in a dropdown menu seems to be a common practice (as you can see on the picture of a drop down menu in Google Chrome). They generaly mean that there is “something” after clicking on it.

Google chrome dropdown menu (french version)

These dots are also sometimes presents in the text of action links and buttons.

I am wondering about their utility and relevancy…

In your opinion :

  • What kind of information should be conveyed by these dots ?
  • How and when to use them ?
  • Is it realy relevant to the user, and easily understood by them ?

How to always show keyboard accelator keys for popup menus?

When opening a popup menu in Windows via the right mouse button, ever since Windows XP, the accelerator keys (i.e. the key to choose one of the popup menu items) are not visible anymore by default. Supposedly there is a way to set this as default behaviour, but where?

If I use Shift+F10 or the menu key (right of the space bar), the accerator keys are shown.

I only found this Delphi-specific question, there answer to which points to the existance of such setting but does not state where: Stack Exchange