Questions tagged [navigation]
Use it for questions about navigation menus and links used in a site.
1,608
questions
1
vote
1
answer
2k
views
Possible parent values for parent of links
I am trying to create links in my Drupal 8 module, following this tutorial. So far, I have a link as follows in my module.links.menu.yml file:
module.admin_settings:
route_name: module.adminForm
...
3
votes
3
answers
3k
views
Is it possible to use tokens in a menu link in Drupal8?
I need to add an option to "User account Menu" that shows the current user name. It is possible to do this using tokens or some other method?
Thanks!
5
votes
1
answer
14k
views
How to display a block with menu child items programmatically?
I need to create block with a list of links menu child items (only first level) of a given menu like this:
Item 1
Item 2
Item 3
With this code I can have the menu items but I don't know how to ...
0
votes
1
answer
547
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
145
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
3
answers
3k
views
Add action links in custom module page
I am writing a custom module for my project which handles a list of content (from custom db table) and content addition, following is my code.
function cp_menu() {
$items = array();
$items['...
2
votes
3
answers
3k
views
How do I show a custom module settings page as tab of another existing settings page?
I am developing a custom module for Drupal 8.0.1 which shows a custom form in admin/config/people/ban/settings.
admin/config/people/ban is the routes used by the Ban module. admin/config/people/ban/...
1
vote
2
answers
6k
views
How to add image field to main navigation menu item
I am having a problem using MYTHEME.theme file to add image field in the menu item object. I need to be able to specify an image for each menu link/item!
function HOOK_entity_base_field_info(...
0
votes
1
answer
24
views
Custom menu is not expanded when the parent menu is selected
I have a Drupal 6.26 site with a custom menu like so:
-Category 1
--Page
--Page
-Category 2
--Page
--Page
...
All Category pages are genrated by a view (e.g. sitename.com/intranet/category)
All ...
1
vote
1
answer
573
views
Group by taxonomy headers
Not sure why I can't do this as it sounds simple, I have:
A content type called 'RSS FEEDS'
A vocabulary called 'Publications' within this I have 3 terms which are 1) NY Times 2) BBC 3) National ...
3
votes
1
answer
637
views
Add awesome font icon to menu item
In my menu I want to add icons. Now when I look for a way to do this, I found a module called Menu Link Attributes. When I configure this on all my menu items, I can't only get it working when using ...
0
votes
1
answer
319
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 ...
5
votes
4
answers
10k
views
Add a class to main menu links
I've searched and found variations of this question but I've never found an answer that seemed to work. I need to add a class to the <li> elements, currently the main menu is rendered like this:
...
1
vote
1
answer
148
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
361
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
5
answers
19k
views
How to get the value / URL of a Link field in a Twig template?
I have a custom block Type with a Link field called "field_link" (for internal links only). Within my block Twig template I want to extract the URL of the link field. How can I do that? I read some ...
1
vote
1
answer
84
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
156
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
41
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?
2
votes
1
answer
329
views
I cannot add node links to primary links
I have a problem that is driving me crazy. I've been trying to solve it for a week now without luck.
The problem is, I can't add any internal (node/xxx) links to primary-links. After I add one, it ...
2
votes
3
answers
6k
views
Adding more variables to menu for use in menu.html.twig
I'm attempting to give menus more variables to work with besides the default menu_name,items, and attributes. This is because making a variable in the preprocess menu hook does not allow it to be ...
3
votes
1
answer
2k
views
How can I modify the Quick Edit Module to have a better UX for end-users?
For a current project I'm working on we're trying to leverage the "In Place Editor" functionality provided by the Quick Edit module.
Our main goals are to:
Have a module that allows us to perform ...
5
votes
2
answers
7k
views
How do I get the absolute URL when using l()?
I want to get <a href="http://site.ru/node/123">New product</a> from l(), and I
call it as l('New product', 'node/123'), but this function generates a URL that is not absolute.
How can I ...
0
votes
0
answers
97
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, ...
1
vote
2
answers
318
views
How to increase book weight range for a same-level chapters
I have a book of 33 chapters. These chapters are numbered with roman numbers: Chapter I, chapter II and so on.I'm a blind user, so I can't use drag & drop reorder. In Drupal 7, weight range is -15 ...
4
votes
1
answer
1k
views
How can I remove all contextual links?
When using the layout builder module, the contextual links module is a hard dependency. This works quite well in the context of the layout builder. But I don't want those links anywhere else, because ...
0
votes
2
answers
2k
views
Links on site adding index.php in URL
I have a Drupal 8 site and am encountering an issue. When I visit the site as an anonymous user and click a link on the menu, it adds /index.php to the url. Then if I navigate to that page and click ...
1
vote
1
answer
423
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 ...
1
vote
1
answer
1k
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 ...
0
votes
1
answer
585
views
How to get Tb Mega Menu working in Chrome?
I have a website and integrated Tb Mega Menu for the navigation. But the problem is my dropdown is not working in Google Chrome, though it is perfectly working in Internet Explore, Mozilla. My version ...
0
votes
0
answers
79
views
Add Image to parent item smartmenus
I have created a dropdown menu using smartmenus module, now I've got a design request asking me to add an image to each parent item. Here's the idea:
My first approach was to try with Menu Items ...
2
votes
1
answer
492
views
How to properly check the menu for emptiness in twig?
I use Simplify Menu to display the necessary menu markup. How do I make sure that the menu is not empty (there are items there) and if there are menu items, they are enabled?
{% set items = ...
0
votes
1
answer
574
views
Sub Menu items not showing
I am trying to create a navigation with a sub-menu in Drupal 9. I added the top level nav item with and used # as the value for the link, and checked "Show as expanded"
Then I created a new ...
2
votes
1
answer
3k
views
Add classes to the menu item <li>?
In hook_preprocess_menu(), I want to add custom classes to the <li> tag.
I tried the following lines of code, one at a time.
$item['attributes']->addClass('section');
$item['attributes']->...
0
votes
0
answers
74
views
How would I create and render, but not save, an entire menu tree programmatically?
I'm trying to pull a number of links from several services, and combine them into a renderable menu tree:
Source one: pull links A, B and C
Source two: pull links D and E
Source three: pull links F, G,...
2
votes
0
answers
45
views
At creation time, why are shortcut titles translated, but menu link titles are not?
The idiom that the community points to for creating menu links usually looks like this (from \Drupal\Tests\language\Functional\LanguageSwitchingTest::testLanguageSessionSwitchLinks()):
// Add a link ...
1
vote
0
answers
56
views
systemAdminMenuBlockPage callback not respecting menu link permissions
I added a custom permission on "admin/commerce/config" to disable access for certain user roles.
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
public ...
3
votes
0
answers
462
views
Menu link tree only loads enabled elements in subtree regardless of parameters
When loading a menu tree without any custom parameters:
$tree = \Drupal::menuTree()->load('my-menu-name', new MenuTreeParameters());
The returned tree \Drupal\Core\Menu\MenuLinkTreeElement[] ...
3
votes
2
answers
2k
views
How can I bulk delete Menu Itemes in Drupal 8 [closed]
is it possible to bulk delete and bulk edit menu items in Drupal 8?
Question for Drupal 7: Any way to bulk delete menu items?
0
votes
1
answer
80
views
How to create a block of links shared by a user?
I am using oembed to convert url to embedded content. I have enabled the oembed input filter in a text format. Now I want to create a block using views to only show the posts which have these links. ...
0
votes
1
answer
25
views
Put menus into separate file for better handling caching with expires
I am trying to clear the page cache of drupal as micro invasive as possible by using Cache Expires and custom logic.
On each page, the menu is shown down to Level 2 in a footer and a hover area.
...
4
votes
2
answers
3k
views
How can I have links to anchors in menus?
How can I add a menu link as /test#anchor and link to #anchor section on the test page?
I need to add a menu item that links to specific section on the target page. Drupal 7 had menu tokens to ...
1
vote
2
answers
500
views
How do I programmatically fix local menus to be shown only for a content type?
I am using the following lines in a links.task.yml file.
x.nodename_updates:
route_name: view.great_view_name1.page_1
base_route: entity.node.canonical
title: 'Updates'
weight: 50
x....
7
votes
3
answers
14k
views
add a link to admin menu bar
I want to add the link to tags i.e. /admin/structure/taxonomy/tags directly to admin menu so that it appears next to "Content" link present on admin menu. How to do it?
0
votes
1
answer
118
views
Replace UID in view tab with name on user profile page
I'm working on a Drupal 8 site. I made a custom page view displaying special content created by the user. The menu tab shows on the user profile correctly by using Pathauto to show the correct address ...
17
votes
10
answers
28k
views
Add class to content field (link)
I want to add a class to the <a> tag of a field that consists of a link and text. (It's a field of type Link.) The name of the field is content.field_c_button_link.
In the template file, I ...
0
votes
1
answer
251
views
Additional attribute for menu link
How I can add itemprop="url" for each link (<a>) in main menu?
So, I need to get from
<a href="/node/114" data-drupal-link-system-path="node/114">Test</a&...
0
votes
1
answer
282
views
<nolink> top items rendered as <a> and remain clickable (give page refresh)
I have a TB megamenu (8.x-1.x-dev) with a few top-level (parent) items that are not links, they should just trigger the submenu to drop down.
According to the documentation I could find, links marked ...
0
votes
1
answer
138
views
Hiding a tab on a user profile based on the user role
I'm making a site using Drupal 8 and I have several roles defined, one of them is Writer. I made a view to show as a tab in the user profile pages called Backlist. If the user is a writer, they can ...
1
vote
1
answer
945
views
Bartik theme main menu
I am dabbling fresh with Drupal 7 and so far having little success with getting the Menu to behave the way I want it to. My CSS and PHP basics are strong, but understanding Drupal's system is in ...