Questions tagged [routes]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
801 views

Remove links from the menu tabs

How can I remove the some links from the Tab, when we are login as a particular user. Please see the below picture. I want to remove the tab Items maked in red rectangle (deny access to this link). ...
0
votes
1answer
36 views

Alter existing route's output formats?

I want to alter the entity.node.canonical route so that when it is accessed using ?_format=json it will return the rendered node in JSON. So far I have created a RouteSubscriber that alters the route ...
0
votes
1answer
2k views

Trying to get fullPage.js implemented, but how to add data-attributes?

This is such a great script called fullPage.js I managed to load the js file and css file and even with the Void Menu Module, managed to call anchor links, but I'm struggling with the data ...
1
vote
1answer
48 views

How to write test(s) with specific config to test custom access checks?

I have built a custom module that alters some of the User routes (view, edit, delete) to do 3 things: Forbid account editing, except a user who has 'administer users' permission Forbid account ...
3
votes
2answers
1k views

Cannot access Administration > People page

I cannot access the People page. There is no error message. If I click on People in the menu bar, the Administration home page is shown. The other Administration pages are accessible. Similarly, ...
0
votes
1answer
23 views

How to update route cache when saving an entity?

I have added a custom access check to the /user/{user} route: class RouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ protected function alterRoutes(RouteCollection $...
24
votes
1answer
30k views

Get the route name of the current page

The route name of the current page is available in page.html.twig? The page is generated by the default feedback form.
7
votes
3answers
1k views

How to use URL parameter and page callbacks for tab menus correctly?

I'm using Drupal 6 and I'm trying to display two tab (menus) on a page that has the URL /vehicle_info. Both pages that the tabs link to should take a node's nid as parameter. My current code looks as ...
6
votes
2answers
2k views

How to set required POST parameters for routes

With GET method we can do something like this example.user path: 'example/{user}' defaults: _controller: '\Drupal\example\Controller\ExampleController::content' requirements: ...
1
vote
0answers
189 views

Make Drupal menu router to ignore a path that belongs to another website

I have Drupal running at http://api.site.com. My conf file is: <VirtualHost *:80> ServerAdmin admin@site.com DocumentRoot /var/www/html/drupal ServerName api.site.com ...
1
vote
3answers
4k views

How to get node url of selected language?

I have a node with an array of multiple languages. [19] => Drupal\node\Entity\Node Object ( [in_preview] => [values:protected] => Array ( ...
3
votes
4answers
5k views

Remove or hide the “View” tab on a node [closed]

I know how to rename "edit" or "track" tab on user page and node page. Here's the code, it might help someone. <?php function MYMODULE_menu_alter(&$items) { // drupal_set_message('Menu ...
0
votes
0answers
27 views

How to check “_custom_access” for whole website and not module/path?

example: path: '/example' defaults: _controller: '\Drupal\example\Controller\ExampleController::content' requirements: _custom_access: '\Drupal\example\Controller\ExampleController::...
8
votes
2answers
2k views

What is the equivalent of hook_translated_menu_link_alter() to Alter a menu link?

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; if (!...
0
votes
0answers
30 views

Difference between adding single parameter vs adding parameter in entity?

Under custom_changes.routing.yml For argument {first_arg}, I am adding default value under defaults custom_changes.argument: path: '/arg-demo/{first_arg}' defaults: _controller: '\Drupal\...
0
votes
1answer
32 views

How to get list of all keys defined in the routing e.g path, defaults, options etc and how can we add new custom key?

route_with_two_nodes: path: '/foo/{node1}/{node2}' defaults: _controller: '\Drupal\example\Controller\ExampleController::foo' options: parameters: node1: type: entity:node ...
2
votes
3answers
941 views

Can we have multliple routing.yml files in a single module?

I have more than 50 menus which I need to create custom. as per the module structure, we need to create routing.yml in root folder. but I want to do something like this below: myModule - ...
1
vote
2answers
371 views

How can I include a dropdown in menu_local_tasks tabs?

I am trying to include a Bootstrap style dropdown in the local_tasks tabs on a section of my website. I thought I might be able to accomplish this with the 'theme callback' option of 'HOOK_MENU', but ...
0
votes
1answer
23 views

Template suggestion doesn't work with a custom menu link (custom route)

In a module I have created a custom link by creating a custom route inside the mymodule.routing.file.yml and the mymodule.links.menu.yml file. In my theme.theme file I have defined a hook_page_alter ...
2
votes
2answers
379 views

How can I disable a path from a view?

I have some views I want to keep, and maybe use in the future. currently I am not using them and want to disable the path, or leave it as "No path is set". but all the I'm I am getting the following ...
0
votes
2answers
386 views

How to avoid url conflict when defining menu items, and make sure path without wildcards will be used in favor of path with %?

In hook_menu, I have $path = "events" $items[$path] = array( 'title' => t('Events'), 'page callback' => 'my_events_page', 'access arguments' => array('view my events'), 'type' => ...
0
votes
1answer
424 views

How can I reorder active menu items programmatically?

I have an 'audience' menu which has 4 links. When a user visits one of these links, it becomes active, and I want to push it to the front of the menu item list. Outcomes would like like; Pitchers | ...
1
vote
1answer
356 views

Get the breadcrumbs for a specific node other than the current

I have a list of nodes created by a view. Those nodes tend to have titles that are mostly the same, but since they are in a rather logical hierarchy defined by the menu I'd like to output the ...
0
votes
1answer
419 views

Creating some views fields for a taxonomy menu with the active trail CSS classes?

I have a taxonomy vocabulary which I want to use to create some navigation on my site. Terms: Weather Clothes Calendar Sports I want to be able to pull these terms and put them in the navigation ...
0
votes
2answers
470 views

Tab Tamer - Hiding tabs based on Roles

Tab Tamer Module only does but so much. I want to hide a tab for anonymous users and have it active for other admin users. This just turns it off completely. Any ideas?
1
vote
2answers
3k views

Disable caching on a route

I have a route with a parameter, e.g. /r/{app_id}. The controller extends ContainerInjectionInterface. The method either returns a render array or a new TrustedRedirectResponse. I believe I have a ...
0
votes
2answers
412 views

Altering the type of a menu item to local task (tab)

I've searched for hours but I can't find a good answer on how to alter the type of a menu item to local task (tab). The private messages 7.x module (when aided by privatemsg_filter) exposes the ...
1
vote
1answer
511 views

How to change autocomplete_route_parameters value on change of select option?

How to change autocomplete_route_parameters value on change of select option? I have a form element and inside autocomplete_route_parameters, I want to change $langcode value when I select any ...
12
votes
3answers
6k views

Redirect Anonymous user to login page

I want if user not logged in and visit any page of my website except my REST VIEWS routers I redirect him/her to login page in drupal 8, I found this solutions for drupal 7 but didn't find any ...
5
votes
6answers
13k views

How to add / remove tabs from user profile?

By clicking on the "My account" link that on the secondary menu on the site, the user is redirecting to the user's profile page. In this page there are many tabs. Some tabs are there originally, and ...
0
votes
1answer
42 views

Scoping an admin link to only show for certain node bundles

I have 2 node content types / bundles, A and B. each A has a relationship with multiple Bs. When on the edit page, node/%/edit, for A, I want to show a link to the list of related B so that an editor ...
0
votes
2answers
403 views

Titles not showing for tabs pages

Below is the array in my hook_menu The only issue that I have with it is that the titles are not displaying for tabs pages (the last three array collections). They are showing the title for the ...
0
votes
1answer
417 views

Entity reference of a menu link gives Restricted access instead of the real data

I am trying to create an entity reference of a "menu link", but instead of having the menu link name I got "- Restricted access -". It seems to be the same problem with wysiwyg profile. I'm using the ...
0
votes
1answer
74 views

Why is $form array empty when extending FormBase or NodeForm

Why is $form not upcast with the requested bundle's fields for the default Form Mode for GET requests; and with the entities' values for other method requests? My form: namespace Drupal\tam_api\Form;...
1
vote
1answer
33 views

Get unsaved node from route parameter

What I want: In hook_media_presave I want to set a field value according to the same field on the referring node. By the referring node, I mean the node where the media entity is created through an ...
2
votes
3answers
664 views

taxonomy menu select list with redirect when a menu item is selected

I'd like to have a taxonomy drop-down list like the one in www.1mobile.com. When I select an term, it should go to the respective page, showing products concerning with selected term. I tried Custom ...
1
vote
1answer
74 views

How can I change Menus depending upon domains (url name)?

I want to change main menu items depending upon domain and sub domains url in a single site. I could have done it easily with roles, but issue w.r.t anonymous users. How would I show or not certain ...
3
votes
3answers
2k views

Adding menu with description like mega menu [closed]

I would like to create a menu with a description of the menu like megamenu. My menu looks like the following model: How can I create this?
1
vote
1answer
424 views

Drop Down Menu in Alphabetic Order

I have a Drupal Website and a few Drop Down Menus in there which comprise of a list of products. However , the list of products does not appear in alphabetic order. I tired "reset to alphabetical" for ...
1
vote
1answer
396 views

OG menu default links are not adding up

I am using og_menu 7.x-3.x-dev I am trying to create some default links to the og menu, but links are not adding.With a new group node its creating the og menu but the default links are not coming.Do ...
-1
votes
2answers
668 views

Retrieve argument in hook_menu() item url

On my custom module, I defined the following hook_menu() function. function motel_events_menu() { $items['ajax/pastevents/%'] = array( 'title' => 'Get Past Events', 'page ...
1
vote
1answer
39 views

Set default menu link as default menu?

I have sub menu of Main menu. I need to set 2nd sub menu as default menu, so when user visit a site 2nd sub menu should open.
3
votes
2answers
1k views

hook_menu() wildcard problem

I can't get the wildcard from a hook_menu to pass it to a callback function Here is what I have: function spin_menu() { $items = array(); $items['spin/login/%'] = array( 'title' =&...
1
vote
1answer
44 views

Customizing menu link output (add badge)

I am new to drupal. I want to customize menu link <ul class="nav nav-tabs sub-menu"><li class="menu-1308 first active"><a href="/" class="active">Top</a></li> <li ...
0
votes
1answer
64 views

How to alter main_menu for logged user?

I would like to alter/change structure of main menu links (programmatically!) for logged in users. What is the simplest way to do this?
1
vote
1answer
399 views

How to add subtitle for menu items in Nice menu in Drupal 7

I'm using nice menu in my durpal-7 site.I need to show a subtitle for each menu item.How can this be done ? I'm new to drupal so it would be great if you could help me.
3
votes
1answer
413 views

Limit menu items available as possible parents on node creation

As I create a node I want to assign i to a menu item parent. I know that I can limit it to what menu(s) are available on: /admin/structure/types/manage/my_type But it would narrow it down to "only ...
2
votes
1answer
677 views

Add Meta tags and Title on hook_menu “page callback” [closed]

How to add Meta and Title tags to the document head on hook_menu "page callback"? Drupal 7
1
vote
0answers
56 views

Using active trail as url path

I would like to use the active trail menu as url path by altering pathauto? Can this be performed?
1
vote
1answer
2k views

Is there a way to show all routes used?

I want to get a list (dump) of routes used? Example: /user/register /user/logout /custom/route /node/27/some-description