We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [routes]

Using a term introduced in Drupal 8, routes are the paths to which modules respond.

Filter by
Sorted by
Tagged with
4
votes
6answers
11k views

How do I insert a <span> </span> tag inside the <a> </a> tag on my main menu

I have asked exactly this question on Stack Overflow, but it makes more sense to ask it here. I'm trying to make the text between my tag not display by wrapping it in a and then styling that. I've ...
4
votes
3answers
5k views

How can I add a direct link to the edit account settings page in a menu?

Ok, I must be missing something obvious, but I'm having trouble adding a link to user/%/edit to the main menu. In the Menu UI, I clicked "add link," set the title to "Account settings," and then was ...
4
votes
2answers
7k views

How to create views tabs in D8?

I can't get views tabs to work in D8, following the exact UI procedure that does work in D7. To be more precise, in D8 at /mypage I see no tabs at all, and at /mypage/tab2 and /mypage/tab3 I do see ...
4
votes
3answers
3k views

How to resolve my 404 error when using hook menu?

I've a custom module named workingmodule. I get a 404 when visiting domain.com/workingmodule. My module is enabled, and I cleared the cache. This id the code I am using in workingmodule.module. /** ...
4
votes
6answers
8k views

Why does menu items start disappearing

In Drupal 7 some menu items, even though they exist in menu_links db table, do not appear in the menu. I wonder if it has something to do with cache, but I have disabled the cache and cleared it. If ...
4
votes
3answers
3k views

How do I use variables in links.task.yml?

I have a local links.task.yml file to display the tab for the node data , But it seems to have a problem passing argument to the path . As you can see i am extending the node's basic fetaures like ...
4
votes
5answers
8k views

Post the same menu as two different blocks?

I have a menu called main-menu. I want to post it twice as a block: one block with a main-menu in the header, and one block with a main-menu in the footer. But Drupal 7 will not allow it. Drupal 7 ...
4
votes
1answer
2k views

Assigning custom class to nested menu UL elements [duplicate]

I'm trying to theme my menu to alter the default UL classes. So far I'm working with the following function: function theme_menu_tree($variables){ return '<ul class="my-class">' . $variables['...
4
votes
1answer
10k views

How to give anonymous user access in a menu hook?

I have a module with a menu hook that I want to give access to everyone. At first I had simply function hook_menu() { $items['site_search'] = array( 'page callback' => 'my_callback', ); ...
4
votes
2answers
9k views

HOOK_menu_alter to remove Main Menu items for specific user roles

I'm trying to add a menu link (admin/people/create?operator=1) to the Main Menu only for the user role of 'Supervisor.' I have tried to do this: function mymodule_menu_alter(&$items) { if(...
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
3answers
3k views

How to alter the visibility of a menu tab for a page created in Views?

I have a View that is a primary tab on the user profile page. The user profile tabs look like this view | edit | menu-item-to-hide. If the person viewing the page is does not have role of admin or the ...
4
votes
1answer
4k views

How to allow a route to a user as long as he has the good role?

Maybe this is a noob question but here goes: I have a menu a menu that contains four links. However, I need one of the items to be accessible only if the current user has "beneficiary" as role. ...
4
votes
1answer
2k views

Custom validation of route parameters

I have something like the following on my .routing.yml file: my.path: path: '/my-path/{node}' defaults: _form: 'Drupal\mymodule\Form\MyForm' requirements: _entity_access: 'node.update' ...
4
votes
1answer
1k views

How do you pass more than one node to a route?

I am working on converting a drupal 7 site to drupal 8 for some practice with 8. In my drupal 7 site, I have a custom hook_menu declaration with the following: function solution_menu() { $items = ...
4
votes
2answers
2k views

How to get language specific path in twig?

In a twig template you are able to get a relative path by using {{ path('entity.node.edit_form', {'node': nid }) }}. The path will be in current language. Now I need to get the path in a specfic ...
4
votes
1answer
6k views

How to specify a twig template for a custom Drupal 8 page?

I'm trying to create a custom Drupal 8 route with predefined content, like /about-us, which is not a node, just a standalone page. The following tutorial is good only up to the point where I need to ...
4
votes
1answer
5k 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
2answers
1k views

Bypass drupal theme with hook_menu() function?

I have a page within Drupal administration where I want to bypass all of the normal Drupal theming and calculations to only show the HTML that's returned by the function. Is this possible? $items['...
4
votes
3answers
2k views

Access callback for blocks

We have "access callback" and "access argument" for defining the access to pages. What is the way to restrict showing blocks? Can "access callback" also be defined in hook_block_info(), or through ...
4
votes
4answers
1k views

Node Reference, and Entity Reference are great; I need “Menu reference”

Is there a Menu reference module I can use to attach menus to nodes, and render them on the page?
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
1answer
662 views

Create a path to node/add in twig

Can I use the path() function in twig to create a link to a non-node entity add form. Taking the group module as an example, if I want to create a link to the 'group/add' page in twig can I use ...
4
votes
3answers
949 views

Routing match everything

i want to match in a route a 'random' URL with a random sub path, fox example: /example/1/a/b/c /example/c3/s ... i implement this route in my .routing.yml file modulo.validator: path: '/example/...
4
votes
5answers
4k views

Any way to bulk delete menu items?

I just deleted 25 menu items and it took me some time to do it. Just wondering if is there any way (module) to bulk delete menu items.
4
votes
2answers
7k views

Render main menu in page.tpl.php, with override from template.php

In Drupal 7, I'm trying to add a <span> tag inside the <a> tag of an item in the Main Menu, but it only works for the 'Navigation' menu which is a block, however, I am trying render it ...
4
votes
1answer
4k views

Menu secondary tabs

How do I create secondary local tasks with hook_menu in Drupal 7? For instance, if I wanted to add a new tab to a node, that presented multiple tasks beneath it? View Edit Update Price Photo Person
4
votes
5answers
3k views

Using the URI to highlight menu items

I have a content type on my site called "Articles". I created a view that lists the nodes of this content type. It's path is "/articles" For that view, I created a menu item in my main menu, "...
4
votes
1answer
990 views

Using a node editing form on a page that not a node edit page

I have created a menu item, as reported below. I have taken the form ID from the page source (form id=listorious-list-power-100-node-form) but when I go to the specified URL, I get the following error:...
4
votes
3answers
5k views

How do I hide the main menu items?

I have users who are the owners of some nodes, and each node has a menu link in the main menu. Users can only see the nodes they own, and they cannot see other user's nodes. The problem now is that ...
4
votes
1answer
2k views

Create a dynamic Tabbed View from Group By

I created a View which show all the content tagged with user flagged terms and group the content by Term Name. Right now I am trying to make each group appear in a tab, I don't know how to achieve ...
4
votes
2answers
775 views

Wildcard Loader function called multiple times (_load)

I have a loader function which is called excessively whenever the user accesses the page. Naturally, I only need it to run once per page request, instead, it is called multiple times. Earlier the ...
4
votes
1answer
2k views

How do I override menu items with my own implementation?

My specific use case is this: I don't want users accessing the user/%user/edit menu. This is awkward because it's quite embedded in Drupal, e.g. forgotten password system. I want the drupal form for ...
4
votes
4answers
5k views

Set a main-menu item as active with custom code

I want to set a menu item of the main menu as active (class="active"). I'm specifically looking for a hook or function, not a contrib module. I have seen recommendations for Context, and I have ...
4
votes
5answers
3k views

Putting items in multiple places in a menu

I'm trying to set up a menu layout which has two links to /biblio; one under "Researchers", and one under "Staff". This is for convenience, as if you are looking under "Staff", the "Researchers" ...
4
votes
1answer
284 views

Get route name from path with wildcard

we've wanted to implement a policy to consider some URLs as whitelist, I've provided a config form to admin to enter whitelist Urls, separated by newline, it must support * ( wildcard). sample urls ...
4
votes
2answers
3k views

“Find Content” missing even though user has permission “Access the content overview page”

Problem: User's "Add Content" menu item is available, but "Find Content" is not. User has role Content Editor. Content Editor has permission for "Access the content overview page". User can access ...
4
votes
1answer
5k views

Get information about a menu item

In Drupal 8, you can use system blocks to show menus starting from different levels. For example: Menu item 1 (level1) --- Menu Item 2 (level2) --- Menu Item 3 (level2) Menu item 4 (level1) --- Menu ...
4
votes
1answer
689 views

Views tabs and argument

I have a views with to page displays with following paths: /question/%/popular (page, title - Popular) /question/%/new (page_1, title - New) The views has a contextual filter (argument) tid. I set ...
4
votes
1answer
1k views

How can I use tab_parent/tab_root in hook_menu to have one router item appear as a local task for another router item with a different path?

Say I have the path widget/123 to view a widget, and have another path to edit some properties of this widget at admin/acme/widget/123/edit. In hook_menu it looks like I can still have the admin path ...
4
votes
2answers
3k views

Make the Main Menu have dynamic links based on url

My main menu has links to common things: HOME | PHOTOS | VIDEOS ... etc. Home points to /, PHOTOS points to /photo-galleries and VIDEOS points to /videos The client has added a new feature request ...
4
votes
1answer
6k views

Export menu links with features

I'm trying to export menu links with features but it saves the node id in the feature, but obviously the nid is different in dev, test and production. I can't use UUID because nodes are created in ...
4
votes
4answers
7k views

Disabling the links in menu item

When I visit a page , say 'About Us' I want the 'About Us' in the menu-items to act as a simple text (not as a link). How can I achieve that ? Thank you in advance.
4
votes
3answers
1k views

Display a block only if another specified block isn't visible?

The issue is that I have a Menu Block with parent items that don't yet have child menu items, but eventually might. I want to display another block in place of the menu block if the menu block is not ...
4
votes
1answer
183 views

How do I remove the tab provided by a third-party module?

I'm using the Guestbook module version 6x-2.0. How do I remove the "My Guestbook" tab on user profile pages?
4
votes
3answers
10k views

Taxonomy menu with custom path for taxonomy terms

I am trying to make a taxonomy menu using the Taxonomy Menu module with a custom path for the taxonomy terms. Instead of /taxonomy/term/tid I want /proj/!tid (or ultimately /proj/!term-name but I'll ...
4
votes
1answer
583 views

Improve D8 performance to access a custom REST controller

Context I'm currently upgrading a site from Drupal 7 to Drupal 8. In the D7 version, there was a custom "proxy" module which served back-end services. Requests starting with a /service prefix, such ...
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
2answers
3k views

How do I insert a localized menu item?

When writing a custom module, what is the proper way to insert a localized menu via hook_menu or hook_menu_alter? By localized I mean not only the translated label - that'd be done using the t() ...
4
votes
1answer
895 views

Allow anonymous users to custom menus

I recently inherited a legacy project that I've been trying to work with. I defined a custom menu using the menu hook but it looks like anonymous users can't access that menu and instead gets ...