Questions tagged [routes]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
43 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\...
0
votes
1answer
45 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
vote
0answers
19 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\...
2
votes
3answers
106 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
0answers
24 views

Hiding submenu to certain roles

I am having the below menu structure: I have setup the entire menu structure using Drupal UI and Menu block permissions. Right now the menu shows for all the roles: level1, level2 and level3. However ...
0
votes
0answers
21 views

The quick-start script in Drupal fails

I am trying to install Drupal v 9.2.9 on my web server. I was informed by core/INSTALL.txt that I could run the script php core/scripts/drupal quick-start It stops the installation prematurely with ...
0
votes
1answer
28 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 ...
1
vote
0answers
35 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 ...
0
votes
1answer
58 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
0answers
50 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-...
-3
votes
1answer
103 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 ...
0
votes
0answers
41 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
1answer
62 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
1answer
17 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
vote
1answer
133 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 ...
2
votes
1answer
175 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
2answers
74 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
vote
1answer
98 views

How can I customize the 403 page for specific routes?

On a D9 site, with an existing custom 403 page twig. I've been requested to show a different, variable, message from the "standard one" for a couple of specific routes. I've tried with ...
0
votes
1answer
88 views

Controller on /taxonomy/term/{taxonomy_term} route

I have a regular Controller on the taxonomy term page (the original view is disabled). It works all right to show what I want it to show, however, neither its getTitle nor its access is ever called (...
0
votes
1answer
77 views

How can I add a dynamic redirect on a 404 hit?

I Created a site and URL that returns a 404 Not Found status on www.xyz.com This creates a loss of link equity to the domain and negatively impacts the ability to compete in organic search results. I ...
0
votes
0answers
58 views

How do I add a custom URL for node/add/{custom-content-type}?

I have a custom content type which I fill up with the help of the Forms Steps module. I want to set custom URL for node/add/{custom-content-type}. I tried using a route subscriber and the following ...
0
votes
0answers
53 views

How can I get a route's name if I have the route object?

I have a route object (which may not be the current route's object) and I need to get the route's name, e.g. entity.node.canonical. I don't see any method to get the name directly from the object, nor ...
0
votes
1answer
21 views

permissions for fillpdf URL

I'm using the FillPDF module and the FillPDF online service to render the PDFs. Everything works fine provided I'm logged in as the site admin; however, when I'm logged in as a std. user, I get an ...
0
votes
0answers
25 views

I can't alter the 'entity.media.route'

I want my drupal user to see the media edit form using the frontend-theme, not the admin-theme. In my RouteSubscriber I use if ($route = $collection->get('entity.media.edit_form')) { $route->...
0
votes
0answers
37 views

Alter existing dynamic route to a different route with a User Parameter

In the Open Social distro when you click on an author link it takes you to /user/[uid]/stream. This path is a path to a view. The social_user.routing.yml file includes: path: '/user/{user}/home' ...
0
votes
0answers
17 views

How to add code that will run on visiting a URL, in addition to another module that also has code that will run on same URL, & control execution order

I'd like to make a custom module that runs code when a URL is visited and then allows an existing module with code that also runs on same URL. So in the case of the existing module that runs on the ...
0
votes
2answers
85 views

How do I embed an Ionic webapp?

I am building a partially decoupled Drupal 8 site. Drupal hosts all the content, but I also built mobile apps and a webapp in Ionic. The mobile apps are working fine, and now I want to host the ...
0
votes
1answer
87 views

How can I have default field values for the node add form as arguments in the URL?

I have a path in drupal 6, which allow me to add new content with 2 fields completed. For example, path node/add/my_content_type/4/6 means that I am on page /node/add/my_content_type, and first field ...
0
votes
0answers
153 views

How do I convert URL parameters to lowercase?

We have a routing.yml file in Drupal 8 which contains the following lines. testmodule.res: path: '/subject/{node}' defaults: _controller: '\Drupal\testmodule\Controller\resController::res' ...
0
votes
2answers
207 views

How do I override an entity view controller?

I am trying to override the entity view controller for a commerce product view, so that I can redirect the user based on certain conditions. I am trying to do this through the RouteSubscriber::...
0
votes
1answer
61 views

How to write custom access for a route which redirects the user to another route if a condition is true

If I visit example.route.one and certain conditions are fulfilled I want to redirect it to example.route.two OR else access should be allowed. How Can I achieve this? I tried writing the redirection ...
1
vote
2answers
125 views

Change the path used by a route dynamically

Taxonomy terms have a canonical path of /taxonomy/term/{taxonomy_term} by default, which displays a View with content tagged with that term. For certain taxonomies I would like to use a different view,...
3
votes
1answer
92 views

If multiple routes match a path pattern, how can I tell which one would be used?

If multiple routes are returned by something like the following: $route_provider = \Drupal::service('router.route_provider'); $found_routes = $route_provider->getRoutesByPattern('collection/%...
0
votes
1answer
125 views

Dynamically change the "access denied page" title and body

This is not a question about changing or preprocessing the twig template of the 403 page. I have a controller with an access function called by the _custom_access key of my route. In some circumstance,...
3
votes
1answer
93 views

Creating an API via module routing files that includes csrf verification headers

I am working on migrating a custom API from D7 to D8 and am doing so by using module routing. I have a routing.yml file that looks like so: ytp_user.api.login: path: "/api/v1/user/login" ...
0
votes
1answer
262 views

How to create custom node edit form [closed]

protected function alterRoutes(RouteCollection $collection) { if($route = $collection->get('entity.node.edit_form')) { $route->setDefault('_entity_form', '\Drupal\alerts\Form\...
0
votes
1answer
159 views

Bearer Token in url is not parsed by route

I Installed Drupal 9.1.0 on a VPS running on Ubuntu 20.4 and using Nginx 1.18.0, with Composer 2.0.8. I installed two modules (Token and Devel) and a theme (Barrio) using Composer. I can enable the ...
0
votes
1answer
64 views

Is there a way to get the controller class from a Request object or any other service class?

My controller class holds some not-so-easy logic to receive some data from a route parameter I need in a block plugin. As this block will only be rendered on this specific route, I would like to ...
0
votes
1answer
116 views

How do I create dynamic routes where the changing part is at the beginning of the path?

I need to create custom module routes like the following. /ireland-dummy-page (IE) /uk-dummy-page (UK) /dummy-page (global) How can I write the route paths for this scenario? Do I want to write ...
0
votes
0answers
27 views

Route to Url with contextual filters [duplicate]

I'm looking for a way to convert a route to an Url with contextual filters added. I can do it manually and it works, but I still think there should be a better, "Drupalish" way to do it. ...
1
vote
1answer
194 views

Alter existing 'Log In' route so URL includes request_uri as query string

I am trying to alter the existing 'Log In' URL so that it points to a certain location and also includes the REQUEST_URI as a query string that is not encoded. How do I do this? Based on this article,...
4
votes
1answer
257 views

How can I exclude certain routes from maintenance mode?

I am trying to make certain routes exempt from maintenance mode by adding the option _maintenance_access to the route and setting it to TRUE. I think (although I'm not 100%) that this works because in ...
1
vote
1answer
71 views

EventSubscriber returning correct content but status code is 404

As the title says, content is being returned correctly but the status code is 404. I have checked the .htaccess file and the Apache config file as well. All seems to be fine. I have the following in ...
1
vote
1answer
370 views

How can I programmatically get various common user profile related URLs?

I'd like to get the following URLs in Drupal 8: /user/register /user/login /logout /user I already know I can use \Drupal::service('path.current')->getPath() to get the current path. I want to ...
0
votes
1answer
110 views

Altering existing route for translation overview page ie: entity.node.content_translation_overview

I have followed this documentation page : https://www.drupal.org/docs/drupal-apis/routing-system/altering-existing-routes-and-adding-new-routes-based-on-dynamic-ones in attempt to alter access of ...
0
votes
0answers
168 views

Unable to access page when using RouteSubscriber::alterRoutes() to override display for path

Because of a need to be able to combine elements from two different entities - a node and a Commerce product - in one page, I am attempting to implement my own custom controller and override the built ...
1
vote
2answers
1k views

Add custom access check to user page

I would like to add an additional access condition to viewing user pages like user/1. I looked at the following guidelines, but have not succeeded in coming up with a solution. https://www.drupal.org/...
1
vote
1answer
68 views

How can I avoid to return HTML markup for access denied? [duplicate]

I've developed a custom controller that serves as a simple endpoint, POST method. This controller has custom access control. Custom access is done by looking for a header in the HTTP request, by ...
0
votes
0answers
93 views

Access Denied when visiting my custom route

I have a custom module with machine name "mymodule". The mymodule.info.yml file looks like this: name: My module type: module description: 'My first drupal module' core: 8.x Then I have a ...
1
vote
0answers
112 views

Programmatic menu link for a view with contextual filter and no parameters in the path

Related question (my question is when contextual filters are NOT in the path): Generate menu links for a view with contextual filter and parameters in the path In mymodule.links.menu.yml I have ...

1
2 3 4 5
46