Questions tagged [navigation]
Use it for questions about navigation menus and links used in a site.
1,593
questions
0
votes
0
answers
36
views
New pages not included in main navigation but display in sidebar
I have recently inherited this website and was made aware of an issue where new pages that are added to the main navigation are only displaying in the sidebar. I have followed the steps for adding ...
0
votes
0
answers
25
views
How do I link to a Views Page from a systemAdminMenuBlockPage page?
I have a custom module that I have a systemAdminMenuBlockPage in that I'd like to link to various content administration Views pages from. I basically have a custom Configuration menu item doing this ...
0
votes
0
answers
25
views
Retrieve the name of the menu that a menu link is in
Given the code below i can get the menu link of the current page. What id like to know is how to determine what menu that link resides in.
$current_path = \Drupal::service('path.current')->...
1
vote
1
answer
106
views
How do I import/export menus?
I want to import/export all menus of site1 in into site2. Currently I am using the entitysync module to synchronize the content between two sites. I can see there is an option for "Custom Menu ...
0
votes
0
answers
42
views
Custom menu that handles content type creation
I'm a Drupal 9 newbie, and right now I'm on steep side of the learning curve.
I apologize if my question is a bit messy and long. Please bear with me.
I'm on Drupal 9.4.8 with a Bootstap 5 theme.
I'm ...
0
votes
1
answer
29
views
Add theme suggestion to a node depending on the menu it belongs to
I have a mega menu that displays child menu items when you click on a parent menu item in form of a drop-down menu. The thing is that, this menu, also displays cards as nodes and I want to add a theme ...
0
votes
1
answer
26
views
Menu items are displayed differently
I have a multilingual page with the languages Spanish and English.
When I edit the menu items in the backend, my default or original language is English.
Now the menu links in this menu are always ...
0
votes
1
answer
448
views
How do I programmatically alter the links displayed in the main navigation menu?
The main navigation menu in the site I am currently working on has a lot of menus. I want to hide the disabled ones.
I figured out that it is rendered via the menu_edit_form form.
entity.menu....
0
votes
1
answer
193
views
How to get menu Attributes from a theme's preprocess function?
I am developing a theme and trying to send custom vars to a twig menu template (since it pulls data from config) and have a loop to add variables in preprocess:
foreach($attributes as $attribute => ...
1
vote
0
answers
24
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 ...
1
vote
1
answer
127
views
How edit or alter the links in the secondary toolbar?
I'm on D9.3.x with Gin theme and Gin Toolbar.
I need to edit the link available in the secondary toolbar.
Namely, I'd need to hide the shortcuts link for everyone and hide the edit profile sub-link ...
0
votes
1
answer
371
views
Add target="_blank" in menu items (main navigation)
I use Drupal 8.9.3 with custom theme. I need to do a menu item on the main navigation who go on an external link.
I would like to add target="_blank" on this link, but I don't see where I ...
1
vote
1
answer
39
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 ...
0
votes
0
answers
51
views
Get link value from menu link
Let's say I have created a new menu node under Structure -> Menu.
The name of the menu is "Footer" and for this I created a new "Menu link" called "imprint" which has ...
0
votes
1
answer
241
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:
...
1
vote
1
answer
37
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
37
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 ...
0
votes
1
answer
45
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 ...
0
votes
1
answer
214
views
theme_preprocess_menu is not seeing main menu
Background: I have an event website where I want to hide the event registration menu item when registration for the event is closed.
theme_preprocess_menu is not triggering on anything except '...
1
vote
1
answer
225
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
55
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 ...
-1
votes
1
answer
25
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
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 /...
1
vote
1
answer
392
views
Dynamic language links from menu?
I am trying to find a way to do the following:
Add languages to Drupal 9 menu items
Translate content/menu links
Provide (from the Main Navigation) a list of languages the current page is translated ...
0
votes
0
answers
344
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
36
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 ...
-1
votes
1
answer
209
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....
0
votes
0
answers
24
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 %}...
2
votes
0
answers
118
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
1
answer
102
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
77
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
votes
1
answer
117
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-...
0
votes
1
answer
255
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 ...
1
vote
1
answer
369
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,...
0
votes
1
answer
285
views
The "is-active" class is added to the main-menu links only when the site is accessed by an anonymous user [closed]
I use this simple template (menu--main.html.twig) to render the main menu I created.
<ul>
{% for item in items %}
<li>
{{ link(item.title, item.url) }}
{% if item....
1
vote
1
answer
111
views
Is there a way to disable the <nolink> option for menu links?
For our unified Drupal platform, we require all of our sites main menu items to be a page and any sub-pages to show a path following the parent menu item. So if "About Us" (with a path of /...
1
vote
1
answer
29
views
How do I add items from from the user module to a menu?
How do I add the core user module links such as My account and Log out to another menu?
0
votes
1
answer
210
views
Template preprocess to generate Font Awesome markup for menu links
In Drupal 9, I need the ability to prepend Font Awesome icons to menu links.
I have attached Font Awesome 5 JS and CSS assets to my theme via *.libraries.yml.
If I open a menu link in the DOM ...
1
vote
1
answer
96
views
Dynamically load the menu items created from the links.task.yml file
I need to programmatically load the links that are generated from my_module.links.task.yml on another page.
My exact use case is that I have a set of links that are shown when viewing my node page. ...
0
votes
1
answer
192
views
How to make a vertical menu properly?
Good morning all,
Today I would like to ask a simple question about the menus. How do you make a clean sidebar that takes up the entire length of the page? In general, the themes offer only natively ...
1
vote
1
answer
517
views
Restrict Menu Item Visibility by Permissions
I have a module-generated menu (using yaml file) with 5 menu items. My requirements don't allow me to restrict menu item visibility by role because roles can be dynamically added. So I have to do this ...
1
vote
1
answer
55
views
Set local actions - disabled/inactive
I am currently searching for a possibility to set an action to "inactive" depending on something.
I have found the hook_menu_local_actions_alter(&$local_actions), but do not know how I ...
0
votes
0
answers
97
views
How to replace the default page and tab of profiles in the user account?
I installed the "Profile" module on my "Drupal 9" website. When I create a profile type, the module automatically creates a tab in the user account for each profile type.
For my ...
-1
votes
1
answer
37
views
How can I re-organize the user account tabs?
I have a Drupal 9 site. I can't find how to rearrange or rename the user account tabs.
How can I re-organize the user account tabs?
0
votes
1
answer
390
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
0
answers
65
views
Create multiple Menu blocks from the same menu
In Drupal 7, the Blocks page contained a link for 'Add menu block', from where you could create multiple menu blocks of the same menu.
In Drupal 8, menu blocks seem to be generated automatically, ...
0
votes
1
answer
204
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
vote
1
answer
761
views
Create a View Block that shows a taxonomy vocabulary applied to the current node
I have a news section of a Drupal 8 website that contains an ever-growing list of nodes. To avoid a messy menu in the long term, they do not have a menu position assigned but instead are shown via ...
1
vote
1
answer
265
views
Disable menu link for certain languages
I'm looking for a way to disable a single link in a menu for a certain language. From my understanding with similar issues, I'd like to activate translation for the menu link field Enabled since this ...