Questions tagged [routes]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
90 views

How to get the parameters from a URL and a route that is not the current one?

Route from a custom module : custom.route: path: /the/{id}/path Hypothetical url : /the/53/path The goal is the get the id value ("53"). So far, I managed to get the route name from the ...
  • 461
0 votes
1 answer
42 views

Dynamically generate Form API select list of routes to page displays of a known View

Given a known View, how would one dynamically generate a Form API select list of the routes to its Page Displays? In my case, I have a Search API View (view.search) with a default site-wide search ...
  • 2,052
0 votes
3 answers
44 views

Where can i find the path/URL of a module after installing it?

I just installed two modules on a Drupal 9 site: https://www.drupal.org/project/simple_forum and https://www.drupal.org/project/answers. I want to get the URL where all posts/questions are listed and ...
2 votes
1 answer
70 views

checking route access for authenticated role

I'm outputting a link, made using Url::fromRoute(). If the current user is anonymous, and the route is not accessible to them, I'd like to show a 'Log in to use this link' text instead, simular to ...
  • 816
0 votes
1 answer
94 views

How to get route inside RequestEvent

I need to redirect all existing links targeting a few hand-picked nodes to an external domain. I created an EventSubscriber listening to RequestEvents my.services.yml services: my.request_subscriber:...
  • 5,107
0 votes
1 answer
105 views

Alter a route according the current user

I'm on D 9.4.x, trying to redirect the node.add route to a custom one, only when the current user has the right role\permission. So I don't think I can't work in the alterRoutes but I probably need to ...
  • 655
0 votes
0 answers
36 views

Get all url in visibility request_path in block_content if request_path['pages'] is /node/* or /news/*

I am creating a module for the administrator for Drupal 9. The purpose of this module is to show one of the block_content of a certain type in the table as a sample and create 2 links for it: for ...
0 votes
1 answer
43 views

Creating dynamic controllers for the same route

I have a route defined as my_node_action.go: path: '/node/{node}/go' defaults: _title_callback: '\Drupal\my_node_action\Form\Go::title' _form: '\Drupal\my_node_action\Form\Go' options: ...
  • 13
0 votes
0 answers
502 views

Argument 2 passed to Symfony\Component\Routing\RouteCollection::add() must be an instance of Symfony\Component\Routing\Route, boolean given

Ubuntu 18.04.6 Apache2, Postgresql 10, Drupal 8.9.6, PHP 7.2.34 (most of the modules require these versions) I've tried trouble shooting this problem for multiple weeks. I'm attempting to migrate a ...
0 votes
1 answer
28 views

How to forbid acess to a page?

I want to show a "Access denied" (403) page with message "You are not authorized to access this page." for a given route. This will apply to all users in any case. How to do it in ...
  • 919
3 votes
1 answer
198 views

All routes resolve to entity.user.edit_form for authenticated users

This is a new one for me: All routes, for an authenticated user, resolve to entity.user.edit_form. Anonymous users are able to browse all public-facing pages of the site without any problems. This is ...
  • 2,052
1 vote
0 answers
44 views

Count how often a route is called

I have written a custom module that exports nodes in different formats. The module itself works great but now I would to count how often one of the custom routes is called. The desired route in the ...
  • 141
1 vote
2 answers
112 views

Change the "add entity" page title on a custom content entity type using alterRoutes()?

I created a custom content entity type dog using drush generate entity:content. When I go to www.example.com/dog/add, the page title (the one in the <title> tag, not the <h1> tag) is "...
2 votes
1 answer
277 views

How can I make route parameters optional in a routing callback?

I needed to create a route in which the path of the route would be completely dynamic and so I created a routing callback. <?php namespace Drupal\uber_affiliate\Routing; use Symfony\Component\...
  • 858
0 votes
0 answers
15 views

Best way to get a full absolute url from a registered route? [duplicate]

I'm working with a module supplied route, and need to hand it off to an api. That means I need the domain and schema included. I am not finding the right options in the URL class, so I have it ...
1 vote
1 answer
80 views

How do I configure the route to the add form for a content type created as a bundle class?

I've got a custom content entity type, created for me by drush generate and I'm extending that using bundle classes. I've got a MyContentType class and a MyBundle class that extends it and provides ...
0 votes
1 answer
72 views

Redirection from user login to another page for logged in users

Due to requirements with our reverse proxies, I had to show the user login form on a different URL. Well, no problem, I thought, I'll just copy the relevant section from user.routing.yml and display ...
0 votes
1 answer
56 views

Not receiving dropdown of custom autocomplete textfield

I am currently trying to create a postcode lookup which returns a street name in an autocomplete dropdown. To do this I have created a new module containing the following files: src/Controller/...
0 votes
1 answer
30 views

Menu item still visible even though alterRoutes denies access to it

I have the following RouteSubscriber in a custom module: namespace Drupal\frilaering_access\Routing; use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\RouteCollection; class ...
  • 91
0 votes
2 answers
90 views

Authentication from a dynamically generated form

I have implemented a feature for PDF conversion using an external java program based on iText (performance is not an issue, the system is for internal usage only, users are less than a hundred, ...
0 votes
0 answers
178 views

Why is my custom route not working?

I'm writing a module that integrates the Zoom API and subscribes to calls, but I'm stuck on just testing my controller code, as Drupal doesn't recognize the route used by the module. zoom_call_module....
1 vote
1 answer
145 views

Correctly cache route by dynamic parameter

I have a route with an optional parameter like: /foo/bar/{baz} {baz} is optional. When accessing that route by a value for baz, the page contents are correct, but the breadcrumb is incorrect and ...
  • 27.2k
0 votes
1 answer
270 views

Send array from twig to controller via route

I have in my twig a link as shown below and I would like to send a lot of data (array) to a controller. How do I go about it ? Do I use params? what is the best way to handle this in your opinion? ...
0 votes
0 answers
97 views

Password reset links sometimes don't work

I've got this problem where once in a while, when a user uses the one time password link, instead of going to the password reset page, it takes them to the home page. Whenever this happens, in the ...
1 vote
1 answer
45 views

How do I upcast route parameters for entity_revision?

My custom entity is revisionable. I can see revisions, but my revision revert form doesn't work. The route for the form is definited in msul_rovi_games.routing.yml. entity.rovi_game....
0 votes
1 answer
239 views

How to add a top-level link to the Admin menu via the links.menu and routing yaml's

Let's say I want to add an additional link to the admin toolbar after Reports such as Groups does. In my_module.routing.yml I have: my_module.admin: path: '/admin/my_module' defaults: ...
1 vote
1 answer
320 views

How to get parameter from dynamic route in route subscriber

I am trying to restrict access for non admin users on admin/structure/menu so that only admins can create any new links via admin/structure/menu. Now I want that for one special menu with the ID "...
  • 303
1 vote
0 answers
86 views

View with a path of api/VERSION/foo/bar/%node - %node is not being upcast to a Node object

I am trying to create a handful of Views with a REST Export display. They have paths set behind 'api/.../.../.../%node' where %node will be an ID sent to the request to be upcasted. The basic View has ...
  • 27.2k
0 votes
0 answers
160 views

How to get node information in RouteSubscriberBase::alterRoutes

what I'm trying to achieve, is to for some specific nodes set admin theme. I have defined RouteSubscriberBase but how can I get node information here? This code is not working $node = \Drupal::...
0 votes
1 answer
277 views

How can I override a displayed node with the content rendered by a custom module?

I have a path /application, which is rendered by a custom module (through a combination of theme hook/controller/routing/twig). It's basically a mini-application. I also have a Drupal node /data, ...
  • 263
3 votes
2 answers
113 views

String substitution in Views Contextual filter parameter?

In Drupal 9, I have a View called News. The View is displayed at the following path: /news I can edit it at the following path: /admin/structure/views/view/news/edit It has the following Contextual ...
  • 2,052
0 votes
0 answers
249 views

How to deal with "Recursive router rebuild detected." exception error

I am frequently seeing module installation and uninstallation fail with the error Uncaught PHP Exception RuntimeException: "Recursive router rebuild detected." at /path/to/drupal/web/core/...
0 votes
1 answer
349 views

How can I make a custom module link appear on /admin/config?

I have a custom module I'm working on and I'd like to make it configurable via the admin menu. I'm having difficulty getting a form to appear in the admin page. Visting admin/config/MYMODULE does show ...
  • 25
2 votes
1 answer
189 views

Can routing use parameters already in the URL?

I'm actually using D9 to build a system with entities using sub-entities. The main entity system use the following path : /item/{item} Each sub entity is related to a main entity and use this path : /...
0 votes
0 answers
78 views

System updates, now config page errors, drush ends abnormally

After an update failed I'm seeing the following issues. I have tried several things to recover. I do have a database backup, but I am not sure on how to restore using Drush (and I'm concerned because ...
  • 121
1 vote
0 answers
67 views

Custom module routing issue

I've a custom module where I have create the following route: my.custom.route: path: /{someVariable}/my-module/test defaults: _controller: '\Drupal\my_module\Controller\...
  • 11
0 votes
1 answer
77 views

Is there a way to control how RouteProvider caches a route?

Drupal caches routes in cache_data. This happens in Drupal\Core\Routing\RouteProvider. I am looking at a high traffic website with "interactive" search functionality based on a map. When you ...
  • 1,149
1 vote
0 answers
99 views

Add a custom Access callback to the profile module to hide the menu tab for certain users

We are using the Profile module and I'm trying to hide the menu tab on the user's account for certain users based on a value of a field on the user. I have the alterRoute set. namespace Drupal\...
  • 371
3 votes
3 answers
1k views

AccessDeniedHttpException on a route with _access: TRUE

In my custom module I have a few "publication" routes that do not need any kind of authentication. Months ago I learnt that I could achieve this with the following requirements in routing....
0 votes
1 answer
165 views

Route reported as not existing, but I'm not referring to it

Drupal 9.28; I removed some test code, and am now getting the error Uncaught PHP Exception Symfony\Component\Routing\Exception\RouteNotFoundException: "Route "member.test" does not ...
  • 429
1 vote
0 answers
61 views

Custom node routing

I have a product content type with alias: /products/headphone. This product page has two url variations: /products/headphone/wire /products/headphone/wireless Both urls should point to the same ...
  • 129
0 votes
1 answer
156 views

How to add internal path in *.links.menu.yml

I am trying to add an internal link to admin toolbar but I am not able to achieve it. According to documentation we add an internal link in *.links.menu.yml in the below manner but the link is not ...
0 votes
0 answers
286 views

Alter route path within event_subscriber with GET parameters

I know I can alter route path with event_subscriber class AdminRouteModifier extends RouteSubscriberBase { protected function alterRoutes(RouteCollection $collection) { if ($route = $collection-...
  • 431
-3 votes
1 answer
244 views

Show the same content with different urls [closed]

I need to show the same content with different urls. I would like to create dynamic routes when saving a node in Drupal 9. Does this seem the right way? Some other solution or similar module. A ...
  • 11
0 votes
0 answers
123 views

Custom entity with dynamic paths

I am creating a new entity and would like it to be in the users profile. The path should be "/user/{user-id}/documents/X": /* * links = { * "canonical" = "/user/{user}/...
1 vote
1 answer
117 views

How to alter routes defined in route_callbacks?

Usually I alter static routes in routes subscriber: protected function alterRoutes(RouteCollection $collection) { $route = $collection->get('gutenberg.media.load_media'); if ($route) { ...
1 vote
1 answer
29 views

How do I add items from from the user module to a menu?

How do I add the core user module links such as My account and Log out to another menu?
  • 1,385
1 vote
1 answer
602 views

Inbound path processor is not processing

I'm trying to use an Inbound Path Processor to redirect a path(to a webapp based on this tutorial), but Drupal is not picking it up. I tried the following code to simply redirect every page on the ...
3 votes
1 answer
697 views

What is the route for a specific node?

I want to override the user.login route that points to the default login page. I.e. I want that a user who presses the default "Log in" link for the site to be directed to a node that ...
1 vote
2 answers
135 views

What is best practice for passing routing parameters?

In submitForm() I want to redirect to a controller and pass the form values. The form values are all arrays, btw. Here is submitForm. public function submitForm(array &$form, FormStateInterface $...

1
2 3 4 5
46