The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [routes]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
41 views

how do 404 pages work?

How does the 404 page you can define in /admin/config/system/site-information work? I found Drupal\system\Controller\Http4xxController->on404(), but how does that display whatever path I definied in ...
0
votes
1answer
168 views

How to upcast webform submission in custom routes resp. controller?

Using this route: confirm: path: '/node/{node}/submission/{webform_submission}/confirm' defaults: _controller: '\Drupal\mymodule\Controller\MymoduleController::confirm' _title: 'Confirm ...
0
votes
0answers
53 views

Splitting routing.yml in multiple files [duplicate]

I have a my_module.routing.yml file and because of I have multi entity in my module its too big and not pretty. Is there any way to split it for each entity and include them in one file like symfony, ...
0
votes
2answers
43 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
57 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
1answer
65 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
39 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, ...
1
vote
1answer
560 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 ...
4
votes
1answer
281 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 ...
1
vote
1answer
32 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
47 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 ...
0
votes
2answers
596 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
107 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
1answer
29 views

When does hook_menu run?

I need to edit the hook_menu function in my module. I need to add a new link to a menu, and edit the path for an existing link. Is this possible without creating a whole new module? The only ...
0
votes
0answers
35 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
79 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
200 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 ...
1
vote
0answers
131 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
31 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
80 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
237 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
723 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
125 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
86 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
57 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
35 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 ...
3
votes
2answers
1k 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
180 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
185 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
100 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 ...
1
vote
1answer
458 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
292 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 ...
1
vote
1answer
271 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
232 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
149 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
1answer
32 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=$...
2
votes
1answer
69 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
98 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
310 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....
3
votes
2answers
1k 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 ...
2
votes
0answers
252 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
20 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 ...
2
votes
1answer
95 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(). ...
1
vote
1answer
524 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
40 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
707 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
25 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
42 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 ...
2
votes
1answer
39 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
3answers
295 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, ...