Questions tagged [navigation]

Use it for questions about navigation menus and links used in a site.

Filter by
Sorted by
Tagged with
39
votes
9answers
68k 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 ...
30
votes
9answers
64k views

How do I create a link?

Say I am extending The blockBase class to create a custom block, and I am implementing the blockBuild method to create some markup for my block. Something like this: class YourModuleBlock extends ...
27
votes
6answers
30k views

How to add module to admin/config page?

I'm working on a module in Drupal 7. I've added a hook_menu implementation: $items['admin/config/content/mymodule'] = [ 'title' => 'MyModule', 'description' => 'Configure ...
22
votes
4answers
16k views

Non-Clickable Menu Items

In a Drupal 8 site, I want to add menu items with "no link", I was thinking that nolink is allowed but when I entered this, I got error Manually entered paths should start with /, ? or #. Is ...
21
votes
7answers
13k views

How to create an EMPTY anchor-only link with l()?

I'm trying to use l() to get something like <a href='#' ...>, for ajax-calling purposes. https://stackoverflow.com/questions/1698453/drupal-creating-anchor-only-link-with-l is very close to the ...
16
votes
10answers
19k 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 ...
14
votes
3answers
17k views

How do I create menu links programmatically?

I need to add some links to existing menu (or to new) programmatically in Drupal 8.
13
votes
2answers
11k 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?
11
votes
4answers
4k views

No navigation links on 404 pages

When I visit a page that does not exist, I expect to still see the primary and secondary links as on any other page, but what I get is no navigation links in the 404 page. See also No navigation links ...
11
votes
6answers
13k 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. ...
11
votes
6answers
4k views

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

This is a question about the Link module. Since with the Link module you can enter external or internal links both, we strongly rely on it. Unfortunately the number of items to be displayed from its ...
11
votes
4answers
7k views

Export menu configuration [closed]

Looking for a way to export menu configuration. The Configuration management system will export the menu itself, but not the menu links configuration. I am looking for a way to put one of those mega ...
11
votes
2answers
308 views

What is the reason behind the current menu structuring

I'm not much of a Drupal Ninja; from what I saw at http://drupal.org/node/788972, Drupal seems to have a menu structure like Joomla, in the sense that it allows menu items to be created under menu ...
9
votes
3answers
14k views

How to set target=“_blank” for links in CKEditor

I use CKEditor in Drupal 8. I want that every link will open in a new tab of browser. I want that the code look like this <a href="#" target="_blank">my link</a> But if I use the ...
9
votes
2answers
6k views

Remove the 'read more' and 'Add new comment' links on the home page

How do you remove or modify the list of links shown after the content?
9
votes
2answers
4k views

What is the equivalent of hook_translated_menu_link_alter() to alter a menu link? [duplicate]

I want to alter the menu link in Drupal 8. In Drupal 7 we can achieve this using hook_translated_menu_link_alter(). function module_translated_menu_link_alter(&$item, $map) { global $user; ...
8
votes
2answers
10k views

How to programmatically add links to the links variable

I am using Drupal 6 and would like to modify the $links variable to include other links programmatically. I have searched high and low on Google on how to do this to no avail. Does someone know how to ...
8
votes
6answers
18k views

How to add a Login / Logout link in Main navigation menu?

How can I add a Login link to the "Main navigation" menu? When a user clicks on the link, it should take them to the /user/login page. Once they login, the link should change to say "Logout" instead ...
8
votes
2answers
8k views

How to turn a menu tree into an associative array?

I've dig into Drupal menu core to find out a way to build an associative array from a menu tree(eg,the account menu) so that I can output the data as json format. But it seems not possible to do this ...
8
votes
1answer
2k views

What's the “Drupal” way of creating image links?

I know that the correct way to create links in Drupal is to use l($text, $path, array $options = array()). But that only allows for text links. Is there a similar function for creating images that ...
8
votes
3answers
3k views

How do I alter the title of a menu link?

In my website, users can collect some 'points' over time. I have a top-bar menu with some links (e.g. "home", "profile", "logout"). I want to alter the menu item "profile" and add the number points ...
8
votes
1answer
3k views

Create a new Menu in Drupal 8 programmatically

Is it possible to create a new Menu in Drupal 8 programmatically using a custom module? I am creating a custom module, and one of the requirements of the module is that it creates a new menu under ...
8
votes
3answers
4k views

How to add confirmation to ajax link?

I am rendering ajax link as follows: l(t('Click here'), 'mypath', array('attributes' => array('id' => 'my-id', 'class' => array('use-ajax')))); How to display confirmation dialog before ajax ...
8
votes
1answer
7k views

Replacing menu items with images

I'm looking for a way to display a menu items as images (with rollover) rather than the usual text links. I found the module Menu Icons, but as the name implies, it's designed to place the icon next ...
7
votes
2answers
10k views

Can we add the destination query parameter to a link from yml configuration?

When creating a link from yaml ie: mymodule.links.action.yml my_module.my_entity.add: route_name: node.add title: 'Add My Entity' route_parameters: node_type: 'my_entity' appears_on: ...
7
votes
5answers
4k views

How to Rename “Request new password” link?

We want to rename the "Request new password" text on a Drupal's login page to some custom text. In the user.module file, I see that this text is hard coded if (variable_get('user_register', 1)) { ...
7
votes
3answers
8k views

Render menu in twig template

In admin/structure/menu I created a menu. Is it possible to render this menu (with machinename: my_menu) in a twig template? Somehow like: {{ my_menu }}
7
votes
5answers
8k views

Hiding link from anonymous users

How can I hide a particular link in the main menu from anonymous users without making the whole menu invisible?
7
votes
2answers
8k views

How do I alter a language item link?

I am looking to modify the default output of Drupal 8 of links in a certain situation, the language switcher. Ideally I want to be able to do that in a twig template and not have to produce a massive ...
7
votes
2answers
12k 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?
7
votes
2answers
2k views

managed links in Wysiwyg?

I am looking for a systematic way to deal with links in Drupal, like there is for images. For images, you add image field to content type, then install "Insert" module and you can use Wysiwyg to ...
6
votes
2answers
22k views

Show all nested menu links in Drupal 7

How do I display all nested links in <ul><li> format in Drupal 7? The default code only displays the 1st level links even though they are arranged in the Drupal admin menu as nested: <?...
6
votes
2answers
11k views

how to make a field in a view be the link destination to another field?

I am trying to create ads on the sidebar to my site. I have created a content type that has 2 fields; an image field, and a link field. I now want to display the ads in a view by having the image ...
6
votes
4answers
10k views

Open a link in a new tab in the menu [closed]

I'm using Drupal 8 with Bootstrap theme, and I've created a sub-theme and different menus. I've tried to edit the menu twig template but i am not really familiar with Twig. How can I add a menu ...
6
votes
3answers
15k views

Convert link from node/nid to Pathauto url?

Im using Pathauto to make my URLs nice and I may want to change the paths in the future. On some pages Im manually lining to other nodes. The issue is that if I code the nice URL then the link will ...
6
votes
2answers
2k 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\...
6
votes
1answer
4k views

How to show contextual links buttons in templates with minimal markup?

I want to get rid of the most markup in Drupal 8 templates, but still want to have working contextual links. How to do this?
6
votes
3answers
8k views

How do I programmatically update or delete menu items?

I have seen the post on how to create menu items programmatically in Drupal 8, but how do I update or delete menu items in D8? Clarification: by programmatically I mean dynamically so yaml config ...
6
votes
2answers
3k views

Adding classes to menu items to signify what level they are

How can I add classes to the <a> or <li> tags of the main menu to signify which level they are in the menu hierarchy (e.g. "level-1", "level-2", etc.)? The code below shows the first link ...
6
votes
3answers
5k views

Dropdown Menu Dummy Link

One of my menu items I have, I want to make it so that only the child links are clickable, and the parent is not. Is there a way to make the parent a sort of "Dummy Link" just to set a hierarchy for a ...
6
votes
5answers
6k views

How to create a menu for current book

I want to create a menu that will be shown on the node if it is part of a book. For example like this: That menu should be shown for all books, which means I don't want to have a separate block for ...
6
votes
2answers
2k views

Create a link pointing to #

I am trying to make a link pointing to # but am unable to find a method that works. The output i would like to see is <a href="#">Example</a> I have tried a few variations of the ...
6
votes
2answers
103 views

Is there a standard Drupal way to link to 3rd party configuration forms?

I am writing a custom module. On my module's configuration form I would like to provide links to relevant modules' configuration forms; e.g. the cron configuration form. Is there a standard Drupal ...
6
votes
2answers
3k views

Is there a way to create a taxonomy path redirect?

I am trying to create a taxonomy redirect for specific taxonomy URL. Basically what Taxonomy Redirect did for Drupal 6 but for Drupal 7. I have searched the Drupal 7 API for hook_term_path but don't ...
6
votes
1answer
6k views

Creating a Dropdown menu in Drupal 7

My question is how do we get the menu in drop down structure. i.e <ul><li><a></a><ul><li><a></a></li></ul></li></ul> I used ...
6
votes
1answer
443 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 this? ...
5
votes
2answers
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 ...
5
votes
3answers
14k views

How can I change a menu link dynamically? (D7)

I'm trying to change the link of a menu item dynamically based on the language that is selected in the language switcher. Let's say I have the following links in my main-menu: -Home -About -Products ...
5
votes
3answers
5k views

How to open external links in new window?

I'm using the "filtered HTML" text format in the node body with the "convert URLs into links" option enabled. I would like to have all external links open in a new window. How can I do that?
5
votes
1answer
20k views

How to add additional url parameters?

I would like to know how I can include additional URL parameters to a given link? ie: 'news?pid=3' <?php print $path='news?pid=3'; ?> This returns page not found error as the '?' is getting ...

1
2 3 4 5
31