4 votes
Accepted

How can I invalidate the entire cache when saving menu item?

The Simplify Menu module has the problem that it doesn't transport cache metadata and a code like \Drupal::cache()->invalidateAll() doesn't exist. You can add the most important cache tag to the ...
4uk4's user avatar
  • 99.3k
3 votes
Accepted

Can I add classes to individual menu links?

The Menu Link Attributes contrib module adds the option to assign each menu link a class in the admin UI.
Patrick Kenny's user avatar
2 votes

Finding all nodes not referenced by a menu

In Drupal 9 can use this 'menu_link_content_data' table to find whether node has any reference as menu: Snippet code for finding all nodes not referenced by a// Get all nodes. $nids = \Drupal::...
mini_poojasharma's user avatar
1 vote

How can I invalidate the entire cache when saving menu item?

\Drupal::cache()->invalidateAll() does not invalidate the content of all the cache bins; it just invalidates the content of the cache.default bin. The Workspaces module uses ...
apaderno's user avatar
  • 97.4k
1 vote

Hook for hiding menu links based on user access

I prefer controlling this behavior via access to the entity rather than at the menu level because it means that anyone with a direct link to the entity won't have access AND if a user does not have ...
sonfd's user avatar
  • 7,881
1 vote

Include html entities in dynamic menu links

I got one way to solve it: return html_entity_decode('© ') . date('Y') . " " . \Drupal::config('system.site')->get('name'); see: https://api.drupal.org/api/drupal/core!...
piridium's user avatar
1 vote

How to display more than 10 items in link widget autocomplete?

There is an issue on Drupal.org to extend link widget to have limit and operator settings the same way as for entity reference autocomplete widget https://www.drupal.org/project/drupal/issues/3341689#...
Artem's user avatar
  • 11
1 vote

How to show menu tab only for certain node type?

The code below work for me. in the routing.yml mymodule.cache_clear: path: '/node/{node}/cache' defaults: _form: '\Drupal\mymodule\Form\APICacheClearForm' _title: 'Cache Clear' ...
vinhdv's user avatar
  • 1,392
1 vote
Accepted

How to get a menu link UUID from a menu tree item?

The UUID of menu links defined in content, not in code, is the derivative ID of the menu link plugin: $item->link->getDerivativeId(); For setting a parent you probably want the entire plugin ID,...
4uk4's user avatar
  • 99.3k
1 vote

Turn off caching for local tasks menu

The only officially supported way to add cache metadata in a preprocess hook is to #cache in the top level of $variables: $variables['#cache']['tags'][] = 'foo'; $variables['#cache']['contexts'][] = '...
4uk4's user avatar
  • 99.3k

Only top scored, non community-wiki answers of a minimum length are eligible