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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

0
votes
0answers
26 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
29 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
51 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
24 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
52 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
33 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
134 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
27 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
29 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
24 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
43 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
15 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
33 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
122 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
58 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
65 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
22 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
224 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
29 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
31 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
41 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
28 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
27 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
37 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
79 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
186 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
30 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
76 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
44 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
160 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
37 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
132 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
43 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
257 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/...
0
votes
1answer
154 views

How to add a default controller to the <front> route?

Is it possible to add a default controller to the '<front>' route? There's no default controller defined in system.routing.yml. I'm trying to get a handle on it by using the following code: &...
1
vote
2answers
367 views

Alter existing route to a different route for a specific content type node using RouteSubscriber

I want to modify node edit of a specific content type node to a different route . Eg : suppose i have a node edit page route as entity.node.edit_form (core feature) . And now i want to change this ...
0
votes
0answers
9 views

Drupal 8 Panels customization

I am trying to customize Panels and Panels IPE modules functionality in Drupal 8. Basically, while loading a block in a panel page through Panels IPE, I don't want to display the "Title" (along with ...
0
votes
1answer
23 views

routing.yml file doesn't work

I'm working on an existing Drupal 8 site. I'm changing anything in routing.yml. In a routing.yml file I have the following. user_profile_update.callback: path: '/user-update' defaults: ...
0
votes
1answer
24 views

Throw entity field value from submission to route path?

I have created two entities and I want to connect them by route. my edit route is: entity.entity_two.edit_form: path: '/property/configuration/communication/{entity_one}/variant/{entity_two}/edit'...
0
votes
3answers
49 views

How do I make the page created from my module visible only to anonymous users?

I programatically created a page using the following code. /** * Implements hook_menu(). */ function page_prog_menu() { $items['page_prog/custom'] = array( 'title' => 'My Custom page', ...
4
votes
1answer
142 views

Define node array id as parameter in routing

Is that possible to send somehow an array of nids and automatically convert it into and array of nodes? Something like: custom.custom_nodes: path: '/custom/{nodes}' defaults: _form: '\Drupal\...
0
votes
1answer
40 views

Show a different view mode depending on role

Using the group module, when a user views a group I want to show a different view mode depending on whether the user is a member of the group or not. Conceptually this is almost identical to showing ...
1
vote
0answers
30 views

Use a route with an id to mimic a node type but pull from a third party source?

Is it possible in Drupal 8 to create a route like /events/{id} with a controller, and in that controller make a call to a third party API to fetch data and then send that data to a template? It ...
0
votes
1answer
92 views

How to view external url from a route file Drupal 8

How to create a route that opens an external file? As an example I have a xml file in my S3 bucket. (http://bucket_url/file.xml). I need to create a route to open that file from my website. Like if ...
0
votes
2answers
2k views

Pass variables from controller to existing node template file

In the Drupal 8 documentation I have found a way how to pass variable from controller to custom twig template https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-...