Questions tagged [navigation]
Use it for questions about navigation menus and links used in a site.
1,608
questions
0
votes
1
answer
484
views
How do I add a link to the #title property of a checkbox?
I created a custom module for Drupal 8.6, and I want to post a link to my terms and conditions.
This is the code I am using.
namespace Drupal\commerce_agree_cgv\Plugin\Commerce\CheckoutPane;
use ...
11
votes
7
answers
18k
views
How to add fields to menu items
I need to build a main menu that is a subset of the regular menu. The design team thinks it would be better for user to have only the most important links in the main menu and not have everything. ...
0
votes
1
answer
444
views
How to put links in a menu programmatically?
I'm using Drupal 7, and modules such as Service links and Flag.
I would like to put the links proposed by these modules (share or flag) in a menu (main menu or other).
Anybody know the way to ...
1
vote
1
answer
418
views
How do I add a subtitle for menu items in Nice menu? [closed]
I'm using the Nice menu module. I need to show a subtitle for each menu item.
How can this be done?
1
vote
0
answers
33
views
How to disable menus from list of menus per role
I'd like to enable visibility per role of menus placed in /admin/structure/menu .
What I want is to allow, for each menu (Administration, development, Footer etc + custom menus), the possibility for a ...
7
votes
1
answer
9k
views
Drupal 8 Permission to see Structure > Menu
Drupal 8. I want a user with a certain role to be able to see and administer menu items /admin/structure/menu/manage/main
On the permissions page /admin/people/permissions I have 'Administer menus ...
1
vote
1
answer
444
views
How to add a top-level link to the Admin menu via the links.menu and routing yaml's
Let's say I want to add an additional link to the admin toolbar after Reports such as Groups does.
In my_module.routing.yml I have:
my_module.admin:
path: '/admin/my_module'
defaults:
...
3
votes
0
answers
255
views
Creating field on each node
I want to add a field on each node which links to a particular page where module's controller will act. I want to actually add a link at bottom of node, and I want to do this programmatically. But I ...
1
vote
1
answer
54
views
Persist query string arguments across all links in a particular menu?
I have a menu "Display Style Switcher" which has two links: Map, and List. You click Map, you get the Map display of search results, and if you click List you get the list display of search ...
15
votes
5
answers
29k
views
Programmatically create a menu
How can I programmatically create a menu? I have 3 different menus I want to create: The first menu will be placed in the top left of the header; the second menu will be placed below the first menu; ...
3
votes
2
answers
3k
views
Determine which region a menu block is rendered in
I need to re-use the same menu in two different regions, with slightly different markup. My thought was to simply check which region the block was being rendered in, and use if statements to modify ...
7
votes
5
answers
13k
views
How do I programmatically update or delete menu items?
I have seen How do I create menu links programmatically? but how do I update or delete menu items in Drupal 8?
By programmatically, I mean dynamically; YAML configuration files are not going to help.
1
vote
1
answer
507
views
Hide node and file paths in view when printing page
I have a views page that lists nodes that contain uploaded PDF and bibtex files (see here). Everything looks fine when you view the page, but when you go to print it in the browser, the node path (...
60
votes
14
answers
129k
views
How to get the valid URL of a Link field from within a Twig template?
I have a Link field named field_my_link (machine name).
Within a Twig template I can get the link's URL value with this:
{{ node.field_my_link.uri }}
If inside the Link's URL there is an external ...
2
votes
2
answers
1k
views
How to tell if a menu link is route:<nolink> or not?
Trying to theme a menu in Drupal 8, running into a case where we need to add classes on certain links.
In the case of a menu link that is route:<nolink> we need to not add any class at all.
...
1
vote
1
answer
64
views
Problem with auto-generated url alias when attempting to make a third-level menu item
Using [node:menu-link:parents]/[node:title] as the pattern for nodes in Url Aliases works fine for a menu that is only two levels, but if I attempt to assign a node to a third level under a menu, ...
0
votes
1
answer
93
views
How to hide / modifiy ['operations']['#links'] edit / delete under structure -> menus in D8
I am trying to hide the edit and eelete links in the operations menu under structure -> menu for specific roles.
I was just trying to hide the operations dialog at all by this code but it returns ...
6
votes
3
answers
3k
views
How can I add cache context to custom menu link?
I have two routes that receive user as route parameter, and i need a menu link for every one in account menu. So I added in my *links.menu.yml
client_account_links:
deriver: \Drupal\my_module\...
0
votes
1
answer
72
views
Update menu links based on the site URL
I have URLs defined in links.menu.yml file as "route_parameters: {webform: 'abc'}", but I need to update webform value based on the page URL.
If URL has "/type1/" in it, keep ...
2
votes
0
answers
149
views
Disable the "Add Link" button in entity.menu.edit_form for certain roles
I'd like to hide the "Add Link" button in menu.edit_form for certain roles.
Running dpm($form) for this form I can't find that button in there.
In core there is menu_ui.links.action.yml with ...
0
votes
3
answers
510
views
How do you deploy a change to a main menu?
We have a small D7 site. We want to deactivate a main menu item.
On dev server I was able to deactivate it in /admin/structure/menu/manage/main-menu
I believe The menu is stored in the DB, right. ...
0
votes
2
answers
411
views
Tokens in menu link and title
menu_token module is working fine to achieve the purpose. Does the module token_filter has this functionality? I can use tokens in wysiwyg using token_filter but cannot make it working for menu title ...
0
votes
1
answer
1k
views
How do I delete all menu links from a menu using the menu machine name in Drupal 8
I trying to get the existing menu items and then delete them in bulk but I'm getting an error trying to load them.
$query = \Drupal::entityQuery('menu_link')
->condition('menu_name', 'mycustommenu'...
1
vote
2
answers
728
views
How do I add an external link in a module?
I'm attempting develop a module in drupal-8 that provides a link to an external password reset system. Specifically on the login page I'd like a reset my password link that points to a link such as ...
2
votes
2
answers
531
views
How to make menu items of restricted pages visible to all user roles?
On a website I'm working on, logged in users can post their feedback about some functionalities which the website provides. While only logged in users should have access to fill the form, invisibility ...
1
vote
1
answer
433
views
MenuLink vs MenuLinkContent - what's the point?
I'm struggling to figure out relationship between MenuLink and MenuLinkContent.
I'm creating new menu item like:
$menuItem = MenuLinkContent::create($params);
I can also query those elements like:
$...
0
votes
2
answers
65
views
Change default user tab
After logging in, users would be redirected to their user profile page.
I have added a new tab, My dashboard using hook_menu(). Everything functions well.
After the users log in, I would like they are ...
2
votes
1
answer
413
views
How to show a menu link that is hidden because the role has no permission to see the linked page?
I need show a menu link that links to /node/add/article for anonymous users but they don't have access to that page.
I have seen solutions like:
Using an absolute URL (that way Drupal does not check ...
-1
votes
1
answer
31
views
hook_menu() items disappeared and no longer work
I'm feel like I'm losing my mind here. I have written a custom module and implemented hook_menu to add custom admin pages. Last week this worked perfectly - this week they stopped working then ...
0
votes
0
answers
40
views
Set URL alias for dynamically created menu links via MenuLinkContent::create [duplicate]
I am creating a menu link via the MenuLinkContent::create method as follows:
MenuLinkContent::create([
'title' => $createdNodeTitle,
'link' => ['uri' => "entity:node/$createdNodeId&...
1
vote
2
answers
489
views
Permission restrictions deny you access to this broken link
In Reports -> Broken links page for some records it is showing
permission restrictions deny you access to this broken link
Site have only one language also, some of the broken links are showing ...
1
vote
0
answers
26
views
How can I delete bogus links under /admin/structure?
I am running Drupal 9.3.4. I see four bogus links under /admin/structure. See the screen shot below. These were paths used by the Context module that were deleted. They are no longer listed under /...
0
votes
0
answers
584
views
How can I remove or rename tabs from the local tasks block?
I'm using Drupal 9.2.6 with Group module and I want to remove some tabs from local tasks block and rename some of them.
I've created the module and placed above code with hook_menu_local_actions_alter ...
0
votes
1
answer
71
views
Primary tabs display differently for different roles?
In my Drupal 8 site (using the Seven theme), the primary tabs navigation are displaying differently for different roles. See screenshots below.
It would appear that for the limited Editor role, it's ...
2
votes
2
answers
998
views
How do I set the active menu item dynamically for a view?
How do I change the active menu item when showing a view? How do I dynamically set the active menu item? shows how to do for nodes (using hook_nodeapi()), but how can I achieve the same for a view?
I ...
0
votes
1
answer
308
views
Using TB Megamenu, how to close one submenu when I open another submenu?
I'm building a couple of (Drupal 8.9.13 and Drupal 9 based) sites where I use TB Megamenu megamenu module (https://www.drupal.org/project/tb_megamenu) to create the menu. All is working fine on ...
-1
votes
1
answer
429
views
Get class on item.below (child item of menu) inside <li> tag in menu--main.html.twig
Hi I can't insert class in child item of main menu and remove existing.
Part of my code looks like this:
{% for item in items %}
{%
set item_classes = [
'menu-item-edot',
item....
3
votes
2
answers
3k
views
Defining module.links.action.yml with route parameters
How can I pass dynamically route parameters to module.links.action.yml?
My code of module.links.action.yml:
module.group_apply:
route_name: module.group_apply
title: 'Subscribe to group'
...
1
vote
0
answers
50
views
Front menu not showing subitems
I've generated my menu based on the menu template from the stable theme
{% macro menu_links(items, attributes, menu_level) %}
{% import _self as menus %}
{% if items %}
{% if menu_level == 0 %}...
0
votes
1
answer
126
views
Is it possible to render a region in a menu template?
In my Drupal 8 theme I have a template called __menu.html.twig which gets called in my page.html.twig
I am trying to render a region within the __menu.html.twig where I can place blocks.
I have ...
0
votes
1
answer
545
views
Translating Menu Item Programmatically?
I have been trying to translate menu items programmatically but upon saving it just adds the english field value to all my translations.
Below is the code I am trying to execute:
if ($entity->...
0
votes
1
answer
104
views
Show links for all the views in the administrator menu
With the admin toolbar enabled, one of the things I miss from Drupal 7 is hovering through the administrator menu on Structure >> Views and seeing a list of all views and being able to click on ...
1
vote
1
answer
561
views
List all the nodes with the same menu parent ID
I have the following menu in my system.
The parent menu-link connects to a node whose ID is 58. All the sub menu-links have a parent ID equal to 58.
I need to find the main and the sub-menus using 58,...
16
votes
3
answers
17k
views
How can I add items to the Admin Toolbar?
In Drupal 8, I want to add a menu item to the Admin Toolbar with a submenu, with different links.
How can I do it?
0
votes
1
answer
375
views
Menu item extras field in page.html.twig
I need a background image per menu item. For this I'm using menu_item_extras. I added an image field to menu items. This field I'd like to use in page.html.twig.
How can I use this field in this ...
6
votes
3
answers
20k
views
How do I add classes to main menu ul and li?
I want to generate the html elements and their classes to fit my styling of the main menu.
I'm confused by all the near-possibilities offered in the api documentation and by looking at core themes etc....
6
votes
1
answer
457
views
Main menu display description as span tag
I modifed my main menu using the following code, but I need the <span class="description"> elements only for the first level menu items, not for the sub-menu items.
How can I achieve ...
2
votes
1
answer
273
views
How do I add specific CSS classes to each menu anchor? [closed]
I have a menu, user menu, with several links. (Let's say A, B, C, and D.) I want to add classes/IDs for each snchor.
-1
votes
1
answer
248
views
anchor menu description under each menu in menu.html.twig
I am currently displaying the Menu "description" underneath each link using menu.html.twig. by doing this:
{% if item.original_link.getDescription %}
<span class="navigation__link-...
-2
votes
1
answer
64
views
Add a custom link to the contextual menu of every block
I want to add a custom contextual link on the top of every block. there are many answers available on the site but these answers are about adding a contextual link to a specific block. and I need to ...