Questions tagged as ['routes']
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 an error message:
In RouteProvider.php line 206:
Route "user.reset" does not exist.
How do I solve this? I have not set up a database yet. The web server has MySQL and PostgreSQL installed.
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 exist." at /Users/pglatz/dev/wdocs/wdocs-d9-code/www/web/core/lib/Drupal/Core/Routing/RouteProvider.php line 206
I grepped my code and there is no longer a reference to member.test
in any of the yml files (or anywhere el ...
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 node, however within preprocess function or twig, I should be able to capture which variation is loaded (wire|wireless)
I figured I should create a custom module and handle custom routing:
my_module.routing.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 being appeared in the toolbar.
hello_world.admin2:
title: 'Hello module settings'
description: 'example of how to make an admin settings page link'
parent: system.admin_config_development
url: interna ...
I know I can alter route path with event_subscriber
class AdminRouteModifier extends RouteSubscriberBase {
protected function alterRoutes(RouteCollection $collection) {
if ($route = $collection->get('entity.admin.collection')) {
// Set new path for the route
$route->setPath('/admin/entity_admin_collection/newpath');
}
}
}
But I cannot find how to get link with GET pa ...
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 specific use case:
node/1 -> 'How to sign up'
url -> '/actor/how-to-sign-up', '/supporter/how-to-sign-up'
P.S. I need the first part of the path (actor,supporter) for various checks
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}/documents/{document}",
* "add-form" = "/user/{user}/documents/add",
* "edit-form" = "/user/{user}/documents/{document}/edit",
* "delete-form" = "/user/{user}/documents/{document}/delete",
* "collection" = "/use ...
Usually I alter static routes in routes subscriber:
protected function alterRoutes(RouteCollection $collection) {
$route = $collection->get('gutenberg.media.load_media');
if ($route) {
$route->setDefault('_controller', '\Drupal\gutenberg_adv\Controller\MediaController::loadMedia');
}
}
However I this does not work for routes defined in routes_callback, so this does not work ...
How do I add the core user module links such as My account and Log out to another menu?

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 site to /happy
, but after rebuilding the cache, nothing happens; I can navigate the site normally and never get redirected.
/mymodule/src/PathProcessor/MyPathProcessor.php
namespace Drupal\mymodule\PathProce ...
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 provides some help (where the user can click on a link and arrive at the standard log-in form).
Say that the path I want to redirect to is /node/42
. How can I find out what route to return for a specific node?
I beli ...
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 $form_state) {
// get values
$demo_values = $form_state->getValue('demo');
$data_set_value = $form_state->getValue('data_set');
$engineering_degrees1 = $form_state->getValue('engin ...
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 theme_preprocess_page__403(&$variables)
but I couldn't determine the original route.
E.g. using \Drupal::routeMatch()->getRouteName()
I got system.403 instead of the route name I need to check. I've checked solution ...

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 (the second being more vexing, of course). The problem is not with my controller, because using a different route works just fine:
example.content.documents_list:
path: '/taxonomy/term/{taxonomy_term}'
d ...
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 wanted to Redirect the URLs returning a 404 status to the defined closest alternative, or parent category, to reclaim link equity from external domains.
Example: Suppose I am using URL http://www.mysite.c ...

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 code.
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
if ($route = $collection->get('node.add_page')) {
$current_uri = \Drupal::request()->getRequestUri();
...
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 do I see it anywhere when I inspect the object via Xdebug.
I know that I can easily get the name of the current route with $current_route_name = \Drupal::routeMatch()->getRouteName()
, but how can I g ...