Questions tagged [routes]
Using a term introduced in Drupal 8, routes are the paths to which modules respond.
2,303
questions
1
vote
1
answer
64
views
How can I rebuild the cache for a specific route when a node of type foo is updated?
I created a page by a module and the cache of that page must be deleted if a node of node-type 'foo' is updated.
How do I do that?
I read https://www.drupal.org/docs/drupal-apis/cache-api/cache-tags
...
0
votes
1
answer
40
views
In Multisite setup the custom page '/speakers' should available on domain1 site only
I have Multi-site setup , want to make available custom page say '/speakers' on domain1 site but not on domain2 site
I have tried to figured out in routing.yml file to check is there way to pass any ...
-1
votes
1
answer
57
views
Custom module routing is going to page not found
I have a custom module that i'd like to display my webform on a certain page but it keeps sending me to a 'Page not found'.
folder structure is;
modules/custom/custom_webform_display
-...
0
votes
0
answers
90
views
How can I make route optional parameter "dynamic"?
I have a route which need to have the language code as optional parameter:
my_module.my_route:
path: '/custom-link/{langcode}'
defaults:
_controller: '\Drupal\my_module\Controller\MyController:...
0
votes
2
answers
61
views
Set cacheability on a custom route returning XML
I'm working on fixing a custom module that returns XML from a certain route. Essentially what is described in the answers of this question.
Currently this route isn't being cached. I've tried to ...
0
votes
0
answers
18
views
Avoid TypeError when route with type hinted parameter in controller is called with wrong parameter type
We defined a route under which a visitor of the website can find some information about how to get data related to the currently shown entity:
aw_api.open_data.info:
path: '/open-data/info/{...
0
votes
2
answers
54
views
block_content routes have ambiguous paths
I'm trying to convert block forms (the content entity forms) into Gin Admin theme forms. Gin theme provides a hook for this:
function hook_gin_content_form_routes(): array {
return [
'entity....
1
vote
2
answers
43
views
How to pass node argument to a local task form?
Suppose I have a route for a local task like this:
MODULE_NAME.node_options:
path: '/node/{node}/options'
defaults:
_form: '\Drupal\MODULE_NAME\Form\NodeOptionsForm'
_title: 'Options'
...
1
vote
1
answer
49
views
Local task for content node doesn't show up and raises 'Access denied'
After spending two days trying to figure this out, it's probably better to ask for help.
I need to add a custom tab next to View Edit Delete Revisions Translate for content nodes (a local task, if I ...
0
votes
1
answer
709
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 ...
0
votes
1
answer
49
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 ...
0
votes
3
answers
148
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
256
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 ...
0
votes
1
answer
326
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:...
0
votes
1
answer
264
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 ...
0
votes
1
answer
108
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:
...
1
vote
0
answers
1k
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
49
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 ...
3
votes
1
answer
483
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 ...
1
vote
0
answers
49
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 ...
1
vote
2
answers
238
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
539
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\...
0
votes
0
answers
16
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
233
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
114
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
134
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
50
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 ...
0
votes
2
answers
91
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
384
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
360
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 ...
0
votes
1
answer
446
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
137
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
63
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....
1
vote
1
answer
446
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
619
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 "...
1
vote
0
answers
92
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 ...
0
votes
0
answers
248
views
How to get node information in RouteSubscriberBase::alterRoutes
what I'm trying to achieve is, for some specific nodes, to set the admin theme.
How can I get node information in this class?
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@...
0
votes
1
answer
419
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, ...
3
votes
2
answers
198
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 ...
0
votes
0
answers
359
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
754
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 ...
2
votes
1
answer
423
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
131
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 ...
1
vote
0
answers
92
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
1
answer
88
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 ...
2
votes
0
answers
146
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\...
3
votes
3
answers
2k
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
548
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
0
answers
75
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
2
answers
336
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 ...