Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [routes]

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

0
votes
0answers
24 views

Pathauto doesn't take into account my routing file [on hold]

I try to redirect my taxonomy pages to my own url pages. For instance, I want to change urls like "taxonomy/term/id" to something like "realisations/categories/termName-termId" So I went to create ...
1
vote
2answers
27 views

How do I add an anchor attribute to a route?

I've created a route: regions.taxonomy_term.edit_form_header: path: '/taxonomy/term/{taxonomy_term}/edit' defaults: _entity_form: 'taxonomy_term.default' _title: 'Edit term' options: ...
3
votes
0answers
40 views

When a path is associated to more routes, which route is used?

How does Drupal 8 decide which route to use, if there are two routes defined in Drupal 8 via routing.yml that lead to the same path? Of course this sounds like a stupid idea or like a mistake in code ...
0
votes
0answers
30 views

How can I change the user login path to hide the login page

I would like to hide the login page so that it can't be opened by /user/login anymore and instead only by a 'hidden' path e.g. /customer-administration/login. I only want users who know the path to be ...
0
votes
1answer
37 views

Link field title from entity/route

I have a Drupal link field configured to allow both internal and external links and have the title field enabled, but optional. I want users to be able to reference internal entities without having ...
0
votes
1answer
32 views

How to force 403 or 404 on specific route

I have made a custom form to create nodes for a specific content type. Due to that, I want to throw a 403 or 404 on the admin page that creates new node. The route I mean is 'node/add/'. I guess in ...
0
votes
0answers
35 views

Assign a controller to all book pages

I am trying to build a module that checks if user session set in all pages of a certain book. if the session is not set it will be set. I am using a sso system so the user data will come from there, ...
0
votes
0answers
59 views

Block disappears unless I refresh route and link cache

I have a submenu based on the main navigation menu system. This Plugin Block builds the submenu on every page. The links of course change based on the route. Every hour around the same time, the ...
1
vote
1answer
71 views

How to redirect programmatically inside a module to an external url? [closed]

I am trying to redirect to a page after I unset a session. I read this article but I am pretty new to Drupal module building. Here this amazing guy says to do the comming thing: If you know that ...
3
votes
1answer
65 views

How to redirect user page to front page for specific roles

I want to redirect every users page to front page? like if user page url is /user/97 then it redirect to front page if user is not administrator. I want user page inaccessible to other users but only ...
4
votes
1answer
37 views

Get route name from path with wildcard

we've wanted to implement a policy to consider some URLs as whitelist, I've provided a config form to admin to enter whitelist Urls, separated by newline, it must support * ( wildcard). sample urls ...
0
votes
1answer
49 views

Disable user login, register and password reset

I am working on a Drupal 8 site that for all intents and purposes will be used as a company intranet. I'm also using the Social Auth Google module to allow only company-registered GSuite accounts to ...
1
vote
1answer
30 views

Set access restriction for baseroute

Let's say I have the following in example.links.task.yml from a contributed module: example.view: title: 'View' base_route: 'entity.example.canonical' route_name: 'entity.example....
0
votes
2answers
25 views

Missing argument 1 for hook_menu()

I'm getting this error in my custom module. [warning] Missing argument 1 for signin_menu(), called in /public_html/includes/menu.inc on line 2813 and defined signin.module:2 here is my code to ...
1
vote
2answers
73 views

Can I programmatically inject a route parameter?

In my projects I often have some special node (types), for which I'm creating custom admin routes and custom edit forms. E.g. I've got a restaurant homepage offering daily lunch specials. For ease of ...
0
votes
0answers
26 views

Is _access: 'TRUE' mandatory for a public route?

I want a route to be accesed by everyone (logged in or not). I removed the requirements and still I was seeing Access Denied. It worked only when I put _access: 'TRUE'. Why is this mandatory? Should ...
0
votes
0answers
16 views

Best way to show an error message in failed AccessCheck

I have a custom access check, but I don't wan't to just throw a "You are not authorized to view this page" error. I wish to set a message "This functionality is only available for XXX". Is there a ...
1
vote
1answer
39 views

Redirect user on specified route

I know we can easily redirect a path to another path with Redirect module, but what I want to do is more complicated, my condition is when the user has a specified IP and the route is matched with to ...
0
votes
0answers
32 views

Can I require a query string parameter?

In a route, say password_recover/?code=XXX How can I make codea required parameter? i don't have control over the system that appends the parameter to the url.
0
votes
2answers
34 views

Custom submit handler stops working when checking route

I'm trying to setup a custom submit handler, so I can change the redirect URL after submitting comments. Edit: I just want to send users back to the page they were viewing to begin with, but it's a ...
1
vote
1answer
36 views

How to get an entity create route, given an entity type and bundle?

I am the maintainer for Views Add Button: https://www.drupal.org/project/views_add_button , which creates a button (link with classes) in a Views header or footer, that allows the user to add content ...
0
votes
0answers
18 views

How to redirect to a route on form submission? [duplicate]

I am trying to call a route on form submission using ConfirmFormInterface API . My Submit handler is as follow public function submitForm(array &$form, FormStateInterface $form_state) { $...
1
vote
0answers
42 views

How do I set a url query parameter node/{node}/edit for a specific content type?

I'm trying to add a taxonomy term from the node in question as a url parameter, but am struggling to figure out how to do it without just going through the site and modifying all of the links that ...
0
votes
1answer
24 views

disable translatable route object

I've developed a module which generates and displays dynamic content. The title of the page is also generated dynamically in the controller as show below: if ($route = $request->attributes->get(...
0
votes
0answers
30 views

Multiple front page aliases

This question may be simple and I'm overlooking the answer, but I am trying to add routes that are front page aliases and there doesn't seem to be an obvious solution. Basically what I want is to add ...
1
vote
1answer
80 views

Redirect user from a custom access callback

In my module routing I have a custom access callback for a payment page. _custom_access: 'Drupal\mymodule\Form\PaymentForm::access' It checks if the user: is allowed to make the payment (it's their ...
0
votes
1answer
96 views

How do I check if a user may access a given route?

I am trying to render a link from a Url object and verify the user actually has access to that URL, like when viewing a node. For some reason, this always returns FALSE, although the node is ...
1
vote
1answer
37 views

Parameter upcasting in Forms: buildForm works, submitForm doesn't

Route: mymodule.applications.payment_form: path: '/payment/{submission}' defaults: _form: '\Drupal\mymodule\Form\PaymentForm' _title: 'Pay Fee' requirements: _role: 'applicant' ...
0
votes
1answer
62 views

How can a controller change the url reported to browser?

I have got two routes - one is for pausing mail jobs, the other one for listing them. When I click on "pause" - the pause route: does it's thing internally calls the list route with a couple of ...
0
votes
0answers
39 views

How to define caching for OutboundPathProcessor

I've got a customized OutboundPathProcesser that adds GET parameters to URLs starting from a specific node type targetting a specific node id. Basically whenever I'm on a node of type product, I add ...
0
votes
0answers
25 views

Create route with parameter as first argument [duplicate]

For version 3.x of simple_sitemap I need to be able to create a route where the first argument is a parameter: simple_sitemap.sitemap_variant: path: '/{variant}/sitemap.xml' ... The controller ...
2
votes
2answers
507 views

How do I programmatically create a route?

I'm trying to create a route programmatically using this code. example.routing.yml route_callbacks: - '\Drupal\example\Routing\ExampleRoutes::routes' Drupal\example\Routing\ExampleRoutes.php ...
0
votes
1answer
91 views

Show/hide menu link based on changing custom $tempStore value

I'd like to show/hide a main-menu link based on a $tempStore variable the user can set and modify during their session, i.e. user sets $tempStore['vlaue'] = 0; --> menu link is hidden user sets $...
1
vote
1answer
68 views

Default entity ID for _entity_view in routing.yml

I've a custom content entity (created using Config pages module) which is used as a welcome screen / dashboard. Privileged super editors can edit those content entities, normal editors can only view ...
0
votes
0answers
47 views

Changing entity.user.edit_form path results in 403 access denied

I want to change the path of the user edit page because i have made my own page with a custom block. The new path does not contain any user id because i programmatically load the UID into the form ...
0
votes
0answers
75 views

how to inject dependencies into an access controller?

I am altering an existing route and adding a custom access. The custom access is a method that I want to have it in it's own access controller: /** * Alters existing routes. */ public ...
0
votes
0answers
28 views

Custom subfolder for an admin page under Admin > Configuration

I want to create a new subfolder called Example, and inside I will have a Settings link. So in the Admin toolbar should be Configuration > Example > Settings. My example.links.menu.yml looks like this:...
0
votes
0answers
59 views

Custom ParamConverter doesn't work (doesn't give error but return isn't what it should)

I'm learning Drupal8 (for the first time, no Drupal7 or previous knowledge) on a local Vagrant VM and have come up against this little problem. I'm sorry if it's kind of a noob question but I wasn't ...
0
votes
0answers
125 views

menu__account hook with routes

I want to change the basic "My account" and "Logout" to "Welcome, USERNAME" and a logout icon but instead of checking if the url/uri matches I want to check if the route matches. How can I get the ...
1
vote
1answer
151 views

Custom route using access check error with arguments

I have a custom route that needs to check if a user can create a certain group_node:article content inside a group (from the group module 8.x-1.0-rc2). The setting is as follows: mymod.routing.yml ...
0
votes
1answer
140 views

Use JSON instead HTML for access denied on some custom paths

I create a small API for one project using Bathic Authentication. The API consists of some custom paths defined in routes in a custom module. Using JsonResponse() in the controller we send back a JSON ...
0
votes
0answers
24 views

How do I call a block through a JS routing [duplicate]

I can render a form in the controller from the below code \Drupal::formBuilder()->getForm( 'Drupal\custom_form\Forms\myForm' ); Is there a way to call a block from a controller like this? I ...
1
vote
1answer
240 views

Can I get Entity Cache Tags from a Route?

If I have a node object I can use $node->getCacheTags() to get the cache tags for the node object, and I can do the same for other entities. Is there a way for me to do something similar with a ...
0
votes
1answer
68 views

Dynamic local tasks to the same route with slug

I have a route set up with a slug accepting taxonomy terms (routing.yml): example.column: path: '/column/{taxonomy_term}' I would like to add (secondary, although that's not important) local task ...
2
votes
1answer
60 views

Why is my custom parameter converter class not used?

I start banging my head on the table, the wall or anything else... please help me. Here is my my_module.routing.yml: my_module.api.validate_coupon: path: '/api/v1/{coupon_code}/validate' ...
0
votes
0answers
86 views

Custom Entity Type Ajax Form/Action without Confirmation

I have written a module for Drupal 8 which creates a custom entity type. In this module, I have a link/route, that updates a field when the user goes to the custom update page and confirms the action,...
0
votes
1answer
30 views

How to redirect to a specifi page of a view?

Here is the code of a custom form: public function save(array $form, FormStateInterface $form_state) { $entity = $this->entity; $status = parent::save($form, $form_state); $values=$...
1
vote
1answer
37 views

Is it possible or/and how to restrict access to the block on th certain page using route name?

I am trying to restrict access to the block to be accessible only on the route:entity.user.canonical route. Is it possible to define that on the block edit form?
0
votes
2answers
44 views

Show url attibuts in twig

I have this in my routing page function_adh_apport.adh_apport: path: '/collecte/apports/{date}' defaults: _controller: '\Drupal\function_adh_apport\Controller\RapportsController::filtrer' ...
1
vote
1answer
160 views

How do I modify a custom entity delete form?

I have a custom entity "Possession" that I created that has a non-standard edit form route to help facilitate a decending url structure. The routing for the edit form looks like this: entity....