3

Yes, theme regions and CSS are what you need. Basically, from admin/structure/block you place your menu block into one of your theme's region. And then, with CSS you adjust the style of the region to your needs. If the HTML structure does not match your needs, you can also alter the page template of your theme (page.html.twig file). If this file does not ...


2

Hooks need to be written in . module file not in controller. Move your code to .module file and also it should be tabedit_menu_local_tasks_alter tabedit.module <?php /** * Implements hook_menu_local_tasks_alter() */ function tabedit_menu_local_tasks_alter(&$data, $route_name) { unset($data['tabs'][0]['simplenews.newsletter_subscriptions_user']); }...


2

It should be considered good practice to rely on the entity type manager to load entities. First, the pattern is easy to remember and looks the same for any entity type. Just replace menu_link_content with node or node_type or whatever. Second, it supports the dependency injection container to be used in OOP code. \Drupal::entityTypeManager()->getStorage('...


2

Drupal 8 menu links are now content entities. The equivalent to loading a D7 menu link object would be loading a MenuLinkContent entity. This can be done via the static Drupal\menu_link_content\Entity\MenuLinkContent::load() method.


1

You can load all module defined menu links (i.e. links defined in *.menu.links.yml with the MenuLinkManager service's getDefinitions() method and then parse the list for only links defined by your module. $all_module_link_definitions = \Drupal::service('plugin.manager.menu.link') ->getDefinitions(); // Next parse the list for only links defined by ...


1

It is a common request to show reverse connection information through Views. It can be done with the help of reverse Relationships when starting from Taxonomy term type Views. You can find other answers with simple examples where you can learn about how it works. You are looking to list sibling terms, but commonly siblings are usually called nodes that share ...


1

Found a solution here - https://www.drupal.org/forum/support/module-development-and-code-questions/2019-08-03/menu-item-children-not-rendered-in I needed to change "Number of levels to display" under the Navigation block to Unlimited


1

This is tricky as you would expect {% if drupal_menu('main') is empty %} to work for checking if the menu exists or not. In reality, you'll want to use the render filter for twig. So that would become: {% if drupal_menu('main') | render %} I tested this code in my theme's page.html.twig file and it works. e.g. {% if drupal_menu('main') | render %} {{ '...


1

There's no way to do that entirely within links.task.yml. If you see the documentation, you'll see that the only possible keys are: route_name: The machine name of the local task route - this also determines where it's displayed. title: The title of the local action. By default, it will be passed through t() and localized. Strings with spaces should use ...


1

I don't konw if there's a better way to do it now but few years ago I did it using a custom access: https://stackoverflow.com/questions/36496998/drupal-8-how-to-add-task-and-contextual-links-for-specific-node-type/36636263#36636263 In my case it was easier because I was creating the routes in my module. Since your routes are created by views you would need ...


1

Just under Display content of "No results found" I see Display "Access denied" you need to use that one. Denied users won't see the tab anymore. If the display of your view is a page you can even manage the access directly into the "page's parameters" block and restrict the access by user role without using a contextual filter (...


1

Two suggestions to improve caching: Even if you don't want to make a decision to allow or deny access you can return a neutral result to add cache metadata. The custom cache tag can be replaced by the list tag ENTITY_TYPE_list, which is invalidated automatically when entities are added or deleted. The resulting code: public function access(...


1

A file like src/Controller/RemoveTabEdit.php is for a class, not a function. In the specific, it's not for hook implementations, which should always go in the module file. The src/Controller/RemoveTabEdit.php file is automatically loaded when the RemoveTabEdit class is used, but since that doesn't happen, the file is never loaded and that hook implementation ...


1

There seems to be very little information on this matter, maybe it's not that common to try to achieve something like this, but I stumbled across this thread while searching for a solution and I'd like to add my thoughts. The comments stating that links.task.yml is for local tasks is right, but when it comes to external links, it's not that simple. As far as ...


1

Menu Delete module is now available for modern Drupal (Drupal 8 and Drupal 9)!


1

item.content['#url'] gives a render array : However, if you need to extract only the URL which can be anything like frontpage, a node in your site or external, you need to use the .toString() utility. item.content['#url'].toString() Title can be accessed from item.content['#title'] Remember that it's all inside the loop: {% for item in items %} &...


1

I needed to add some classes to my link. field_url is a link field. I didn't have content in the Twig context. {{ node.field_url[0] }} gives me a \Drupal\Core\Url object. {% set link = node.field_url[0] | view %} This is a filter from the Twig Tweak module. It returns a render array. I can now output my link like this: <a href="{{ link['#url'] | ...


1

Actually there is much simpler solution using https://www.drupal.org/project/twig_field_value module <a href="{{ content.FIELD_LINK_NAME|field_value|first['#url']|render }}"> {{ content.FIELD_LINK_NAME|field_value|first['#title'] }} </a> This will work for both internal and external links.


1

You can check https://www.drupal.org/project/simpler_quickedit to do exactly what you need


1

In drupal 8 here is how you would attach a menu-link to the toolbar. Add a file my_module.links.menu.yml to your module: my_module.admin_settings_form: title: 'MyModule Settings' route_name: my_module.admin_settings_form description: 'Custom settings' parent: system.admin weight: 15 Source: https://stefvanlooveren.me/blog/add-menu-item-drupal-...


1

if your looking for a D8+ fix, the Menu Link Attributes module saves a lot of time. You can specify attributes and classes through a YML file or directly to individual links in Admin Menu UI.


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