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

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

0
votes
2answers
46 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
21 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
47 views

user/login not found [on hold]

I can`t access www.rechindebahlui.ro/user/login or register or admin pages... Everything is working fine, like index page, articles, but /user/login, /user, /register etc. gives me: 404 not found ...
0
votes
0answers
13 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
36 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
31 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
31 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
28 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
17 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
39 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
28 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
45 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
62 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
27 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
56 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
22 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
401 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
68 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
47 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
37 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
65 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
19 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
43 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
108 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
104 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
23 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
232 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
40 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
40 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
64 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
29 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
32 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
41 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
119 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....
2
votes
2answers
298 views

how to restrict access in routing.yml based on roles

I know how I to restrict access in the routing.yml file based on permissions, but how can I do it based on roles? This is how to do it by permissions: requirements: _permission: 'access ...
3
votes
0answers
35 views

Detail page route gives error

In my_module.routing.yml my_module.detail: path: '/module/{id}' defaults: _controller: '\Drupal\module\Controller\DetailController::view' requirements: _access: 'TRUE' In template twig ...
0
votes
1answer
18 views

Externally Requesting Browser Test Created URL for Relaxed Replication

I am trying to write a browser test for for a workspace replication via relaxed web services using the multiversion, replication and relaxed modules. For this purpose I set up an external Drupal ...
3
votes
1answer
77 views

Why is my form only redirected sometimes?

I want to have a user register, and be redirected to a node create form. Here's how I'm doing it thus far. The setup I have a route, my_module.register that is handled by MyController::register(). ...
0
votes
1answer
67 views

Hooks and routes not working at all

I have a module called hello_world. I have a hello_world.info.yml file in drupal/web/modules/custom/hello_world whose content is the following. name: Hello World description: Hello World module type:...
0
votes
2answers
37 views

Custom username paths?

I want to be able to create paths like this: /guy1 /guy2 /guy3 It's easy enough if I want /profile/guy1 ... then I can just do this: gg_profile.viewUserProfile: path: '/profile/{username}' ...
3
votes
3answers
237 views

Can I conditionally hide a route (e.g. action / local task)

Consider an action button on a custom entity's canonical page: mymodule.actions.yml: entity.item.action: route_name: entity.item.action title: 'Do something' appears_on: - entity.item....
0
votes
1answer
20 views

Can access arguments only be specified once for all sub-routes?

For example: I would start off by setting this. $items['admin'] = array( 'access arguments' => array('administer users'), 'type' => MENU_NORMAL_ITEM, ); But the anytime after I use admin in ...
0
votes
1answer
39 views

Change routing behaviour for non-existent entities

For my custom entity type called item, I would like to set up routes such that the path: /item/{item} views the entity as normal, if it exists if it doesn't exists, redirects to the create form The ...
3
votes
1answer
34 views

8 - Is It Possible To Create Routes Through The Admin

Question: Is there a way for users to create routes in the admin? Issue: I have a bunch of nodes and tax terms that are being used in Views but no where else. They shouldn't be accessible to the ...
0
votes
2answers
156 views

PHP Warning SplObjectStorage::offsetExists() expects parameter 1 to be object, null given

Updating to 8.5.1 today from 8.4.5, and after a successful update, I start getting the following warnings on every page: Warning: SplObjectStorage::offsetExists() expects parameter 1 to be object, ...
0
votes
0answers
57 views

Access denied to admin on custom module

I get access denied to admin user in my custom module. This is my routing yml file: operatordb: path: operator-database defaults: _form: \Drupal\operatordb\Form\OperaDBForm _title: '...
3
votes
1answer
548 views

How do I define a Route with multiple different paths?

Does Drupal's routing system support a regular expression or other means for multiple route paths? I have a route that I would like to be able to hit from two different endpoints, /api/v1/foo and /api/...