Questions tagged [routes]
Using a term introduced in Drupal 8, routes are the paths to which modules respond.
2,307
questions
0
votes
2
answers
68
views
How to implement dynamic access requirements for a route?
I have a route defined in module.routing.yml, and I want to add a UI in the module to let the user configure what types of access to allow:
Oauth2
JWT
Cookie
How do I do that, since routing.yml is a ...
0
votes
1
answer
30
views
Dynamic URL using route is not working
My {custom_module}.routing.yml file code is as below:
custom_greeting.greeting:
path: '/custom-greeting/{name}'
defaults:
_controller: '\Drupal\custom_greeting\Controller\...
1
vote
1
answer
110
views
Allow the anonymous user access to the user.logout route
Ok, I've tested this against drupal/recommended-project:^8, ^9 and ^10. Nothing else installed.
I want anon users to be able to hit /user/logout. That's the requirement.
IMO, this code (or a close ...
0
votes
1
answer
50
views
"Route does not exist" in JSON:API for custom entity type
I created a custom entity type using drush generate entity:content. I chose to have bundles, and I added a bundle test_bundle.
I can add my custom entities at admin/content as expected.
However, when ...
0
votes
1
answer
69
views
How to disable caching of _custom_access callback
My module has several pages which use a custom access callback. The conditions for access may change from call to call so this needs to be checked every time. When I am logged in, the access ...
0
votes
0
answers
48
views
Can't make my custom dynamic route use custom controller and twig template if I use pathauto aliases
I'm trying to decouple drupal and get data via api calls so that I can use the same data across several drupal installs on different domains. So far I'm testing on the same domain but still can't ...
0
votes
1
answer
120
views
How do I redirect to a different form in a _custom_access routing call
In my D10 application, it is required that I have a parallel user login system separate from the Drupal system (it is a requirement I cannot change). On my routing, I have the following:
...
0
votes
0
answers
28
views
Get current node url in a custom block [duplicate]
I'm trying to embed Discourse comments in Drupal, so I'm tryinig tu use this code snippet in a custom block :
<div id='discourse-comments'></div>
<meta name='discourse-username' content=...
1
vote
1
answer
115
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
52
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
155
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
180
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
151
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
2
answers
100
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
68
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
108
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
1k
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
56
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
257
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
419
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
647
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
452
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
186
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
2k
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
54
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
668
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
54
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
355
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
704
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
562
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
210
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
234
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
77
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
97
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
516
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
563
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
561
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
172
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
84
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
697
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
827
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
100
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
275
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 {
/**
* {@...
1
vote
1
answer
606
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
245
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 ...
1
vote
0
answers
495
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
1k
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
658
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
148
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 ...