People who code: we want your input. Take the Survey

Questions tagged [navigation]

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

Filter by
Sorted by
Tagged with
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
10k 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 ...
5
votes
1answer
21k 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 ...
5
votes
3answers
3k views

Add markup inside a link (in the renderable array) in preprocess field

My question is for D8... I have a field which is rendered as a link. Let say for simplicity that it will be rendered like this: <a href="url">My Title</a> I would like to add a bootstrap ...
5
votes
2answers
659 views

How to modify the link titles shown in /node/add page?

I can modify the menu item title implementing the hook_menu_links_discovered_alter() hook, as illustrated in this screenprint: I changed the menu item title to "Article (Only One Article can be ...
5
votes
1answer
2k views

Create menu tabs with views

How can create menu views tabs of node? In Drupal 7 i can create views like this: when i visit node/1/teaser it's show good. But with same setting in drupal 8. when i visit node/...
5
votes
1answer
3k views

how to render html link within dsm message?

I would like to include a link to the reports page within a dsm message. Here is what I tried: $loglink = l("logs", 'admin/reports/dblog'); $msg= "See $loglink for watchdog messages"; dsm ($...
5
votes
1answer
4k views

How do you clear menu caches programmatically?

I am developing a custom module. In this module, I want to delete menu caches programmatically. For this, I have used \Drupal::cache('menu')->invalidateAll(); // for clearing the menu cache \...
5
votes
3answers
7k views

target=_blank for links in view

I've got a view and one of the fields is displayed as a link. (Output this field as a link is cheked). But now i want those links to have target=_blank attribute. How can i achieve this?
5
votes
2answers
2k views

How can I load a menu programmatically with an active trail set by a provided URL?

Working on a headless Drupal site, and have come across an issue. We have a REST resource that returns arbitrary menus by menu-id, however they always have "active-trail" set to false on every menu ...
5
votes
4answers
2k views

Font Awesome icons in link field

I would like to have a font awesome icon in my link text. <i class="fa fa-pencil"></i>Blogs Since link fields are generated in LinkGenerator.php, they get escaped. if (!SafeMarkup::...
5
votes
3answers
966 views

Issue in converting a HTML Link to Drupal Link using l() function

I have created a HTML anchor link. Now i need to convert this link to Drupal's link using l() function. But i am not getting what i want. I am new to this Drupal environment. HTML Link : <a href=...
5
votes
1answer
5k views

How do I create an ajax link?

I want to create an ajax linking a view (front page, for example). I create an ajax edit link to edit content directely in the node. I success to add a link but when i click to it, a popin was opened(...
5
votes
3answers
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: ...
5
votes
2answers
2k views

How to Bi-directional link two nodes from different content type?

Hello i am new to Drupal. I have used Joomla for very long time and some wordpress. I want to link 2 or more nodes bi-directional. Meaning that if i link A to B, B must be also linked to A. I will ...
5
votes
1answer
2k views

Determine if menu link is current/active

When rendering a menu, in the twig file, you can set a class if item.in_active_trail is set: {% for item in items %} {% set classes = [ item.in_active_trail ? 'is-active', ] ...
5
votes
1answer
17k views

Controlling the height of a jQuery accordion in content page

I have managed to add a jQuery accordion content page to my Drupal7 site by following the instructions/code given here: http://www.chrisherberte.com/blog/drupal-7-and-jquery-ui-accordion. However, ...
5
votes
3answers
5k views

Adding a link to an image

Is there a module or a way in core to have an Image field be a clickable link to a URL that is either entered as an additional setting for the Image field or can be pulled from another field that ...
5
votes
2answers
1k views

Attach a node to a menu link OR attach custom fields to menu links?

My client would like to add content to the top-level links in the main menu, in order to have "Featured" content that is displayed in the drop-down menu. They must be able to choose which piece of ...
5
votes
2answers
600 views

Adding Contextual Links to Ctools Custom Content Type Plugin

Ctools custom content type called Custom Panes shows contextual links when you have access permission and you hover over the pane (much like a block shows the contextual links) which allows you to ...
5
votes
1answer
107 views

YourTheme_links doesn't work on sub theme

I have tried the way described in http://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_link/7#comment-24463 But as it seems it works on the main theme but not on a subtheme. function ...
4
votes
4answers
3k views

Migrating link fields to Drupal 8

I am trying to migrate a link field field_url from a Drupal 7 site to my Drupal 8 one. The link field is compound, it has a title and a url value. In my process plugin I am selecting the right values (...
4
votes
2answers
5k views

Alter menu structure when using Superfish menu

I am using Superfish menus. I wanted to add a <span> tag before each <a> tag for menu links. I tried the following code: function mytheme_menu_link($variables) { $element = $variables[...
4
votes
3answers
3k views

Render image that is linked

I am loading an unmananged image file and would like to render it in a block, but it should be linked. I have an uri (public://...) and I am able to render the image using $build['my_image'] = [ ...
4
votes
3answers
1k views

Link format as a preview [closed]

I'm asking if it exists a drupal module that let you make a preview of a link like the Facebook do. In another way a display format which it gives a preview.
4
votes
4answers
5k views

User picture and name in user menu

I would like to achieve what Acquia did on https://dev.twitter.com/. When you sign in, you can see the user picture and the user name in the right end of the menu bar and that is what I need. I made ...
4
votes
4answers
9k views

Add active class to link <li> using l()

Seems so elementary but how does one get the active state onto the <li> of a link when manually using the l() function? <li><?php print l('Hapiness','my/hapiness/complete', array('...
4
votes
1answer
2k views

Remove default “Home” link? [closed]

In Drupal 8, there is a 'Home' link in the "Main Navigation" menu provided by core. However, you can only disable this link, you cannot delete it. How can I remove it? I don't need it and would ...
4
votes
3answers
3k views

Create link with 'name' attribute only using l() function

Is it possible to create a link using Drupal's l() function without an href? For example, I'd like to create a link like the following: <a name="my-anchor">A link here</a> However, this ...
4
votes
2answers
3k views

Set parent for programmatically created menu links

I'm currently programmatically generating a menu and menu links inside it. This is working but I'm having trouble setting the parents for the links. Here is my current code $langcode = 'es'; ...
4
votes
1answer
6k views

how to add link to null path in menu in drupal 7

I have added superfish menu in menu bar in that one of the link have sub-link. How to add a sub-link with null path. Please help me. Thanks
4
votes
4answers
2k views

Superfish - File not found: sites/all/libraries/superfish/sfsmallscreen.js

I just downloaded and enabled the latest (dev) version of superfish module, as well as the library... I am getting the following error: File not found: sites/all/libraries/superfish/sfsmallscreen....
4
votes
4answers
2k views

Customize the HTML of a link field from a custom theme

I've a Link field named field_home_link, attached to a Content Type named Home, and I'm trying to customize how it is rendered as HTML from inside a custom theme. Instead of the default generated ...
4
votes
2answers
4k views

Drupal navigation always returns a 404 error

I have been given a Drupal site which I have to get it running. I have Apache / Drupal / MySQL up and running, and created a new .conf file in Active Sites, and set the document location to /var/www/...
4
votes
3answers
1k views

How do I exclude a single menu item from the home page?

I have a menu that displays on every page, and the top link for that menu is the "Home" link. The clients do not want this menu item to appear when a user is viewing the home page, but wish it to be ...
4
votes
4answers
10k views

show/hide a menu item based on specific user role

I have a certain number of main menus which need to showcased based on logged in user role. for example user with the role, A can sees few menus and user with the role B, sees another set of few ...
4
votes
2answers
2k views

How can I overwrite existing menu tree manipulators?

Or: how can I prevent unpublished nodes' menu items to be removed in the menu select when the user does not have the bypass node access checks permission, but may actually edit various unpublished ...
4
votes
3answers
2k views

Clearing local tasks cache

Using a deriver, I'm able to produce local tasks for each entity of my custom configuration entity type. So if I have two configuration entity labeled "Foo" and "Bar", I can have similarly labeled ...
4
votes
3answers
235 views

How to create a separate web page menu to be used only on one of my web pages?

My site has a main menu displayed at the top of each page. But one of my pages is about a Parade we host, and it has a lot of content. I would like to create a menu just on the Parade web page. Every ...
4
votes
1answer
2k views

How to put links into description text?

In my field's description, I want to link to more documentation. If I do it like this: $form['field_name'] = array ( '#description' => t('Here are some words about') . ' <a href="http://...
4
votes
2answers
2k 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 ...
4
votes
1answer
2k views

create empty link

I am using the following code. $url = Url::fromUri('javascript:', array('external' => true)); $link = Link::fromTextAndUrl(t("#action"), $url)->toString(); It causes the following error: ...
4
votes
1answer
1k views

Modifying HTML of menus

In my Drupal 7 template, this one line of code spits out all my menues: <?php print render($page['header']); ?> I want to remove extraneous wrapper tags from my menus; for example, Drupal 7 ...
4
votes
1answer
118 views

How to replace the Secondary menu title with the current Username?

Secondary menu - this is the system secondary menu title. I need to replace it with current username, the same as the User menu block has it. I do not want to use the User menu block because of some ...
4
votes
3answers
2k views

Get title from Route

I am trying to print out a few links on a custom page template. I would like to use the title and url from each route. I am trying to print out the title from the route. I know I can get the url ...
4
votes
1answer
332 views

I need to add rel=“nofollow” to the button provided by “views load more” module

I need to add rel="nofollow" to the button "Load More" provided by Views Load More, but the problem is that the anchor is created in views_load_more.module (line 91) this way: $li_next = theme('...
4
votes
1answer
113 views

How do I print a link only if it doesn't lead to access denied

My nodes have fairly complex permissions set on them. I want to display a small edit link on the teaser for a specific content type, only if the user has the permissions required to edit that ...
4
votes
1answer
899 views

How to get a section of the menu tree based on the current node?

I am currently struggling to wrap my head around how the menu tree and menu link services work for outputting part of a menu with some custom requirements. Admittedly I don't have to do this very ...
4
votes
3answers
3k views

How to add a top nav bar? [closed]

I would like to add a Facebook style or StackExchange style top navbar to my site. It should show the username, mini profile pix, userpoints, search box and a few other links. Is there a module for ...
4
votes
3answers
2k views

How to create a custom text input filter?

I am using plain text format. I want to create an input filter for when a user enters #15, it should be converted to a link pointing to the post #15. I want to do this for the Statuses (Social ...

1
2
3 4 5
32