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
19 views

How to define frontend theme (non-admin) for a given node tab route?

In my custom module I want to define a new tab associated with nodes. I have my own custom route file with the required definitions and a Links file to make sure the new route will be displayed as a ...
5
votes
1answer
59 views

Is there a way to partially rebuild the router or invalidate a route cache?

I'm using the Groups module (http://dgo.to/group) to set up groups on a SaaS project I'm working on. I've set up a domain field on the groups, allowing groups to have vanity domain. As such, groups ...
1
vote
1answer
58 views

How to store temporary metadata for the remainder of a request?

I am looking for a way to store some additional metadata for the remainder of a request, that should be removed after the request has finished. Sessions or SharedTempStore store persistent data across ...
2
votes
0answers
40 views

How to get module name from a given route object?

In a runtime context, given I have a route object, e.g. from route name user.register, how do I find the path or routing.yml or other definer of the route? Does Drupal or Symfony provide for this? ...
0
votes
3answers
40 views

Can I create a form with a route like this /rooms/{node.alias}/booking?

I'm working on a booking project and I have to create a form for reservations. I have created the accommodation content type and the url_alias for this is: /rooms/[node:title] Example: /node/1 = /...
1
vote
0answers
38 views

Custom module route to config form deleted, now the site is down

So I have a custom module Domaincheck which had an admin configuration form. Since that one is not needed at all, I decided to clean up and delete the form and route. That resulted in a Symfony\...
3
votes
1answer
22 views

404 Not Shown For Custom Module - Drupal 7

In a hook_menu() implementation, I am defining a route for login. function my_account_menu() { $items['login'] = array( 'title' => 'Customer Login', 'page callback' => '...
2
votes
0answers
68 views

How is a response generated?

A generic basic PHP Application using Symfony uses code similar to the following one. $request = Request::createFromGlobals(); $context = new RequestContext(); $context->fromRequest($request); $...
0
votes
1answer
23 views

Forward authenticated user to user.page on /login uri

If an authenticated user navigates to /login on a Drupal 8 site, she gets the "access denied" error. I want the site to redirect that user to /user (route user.page) instead. Unfortunately my ...
0
votes
0answers
24 views

Pass rendered markup to redirect route

Drupal 8.7.x I have form that passes the outputted data into a template. This template with the data gets rendered into a string like so: : public function submitForm(array &$form, ...
2
votes
2answers
45 views

How can I add an age validator page?

To access the site, all users (except the logged-in users) need to pass through an age gate. They can only leave the welcome page if they are 18 years or older. I started by adding a session to my ...
3
votes
1answer
179 views

Why does this route work with a slash and not a dash?

I have defined a custom dynamic route that works, but isn't ideal: /** * Defines dynamic routes. */ class GuideUnitRoutes { /** * {@inheritdoc} */ public function routes() { $...
1
vote
1answer
31 views

How does routing order / matches effect performance?

I have all the following GET routes defined in my_module.routing.yml: my_module.members_uid: path: 'users/{user}' my_module.members_uid_gid: path: 'users/{user}/group/{group}' my_module.user....
0
votes
1answer
29 views

Is it possible to invoke cron within a hook or route class?

I'm using the Deploy suite, which requires cron to be run after a deployment is created. However, when I try to execute \Drupal\Core\Cron::run(); from hook_entity_create() or from a route Class, it ...
0
votes
0answers
38 views

503 Service Unavailable error in all pages except added to my route file

I have a D8 web with some views and pages. If I log in with administrator user, all works good. If I log in with a normal user, I get 503 service unavailable error after some seconds of load. It ...
0
votes
1answer
27 views

hook_menu() item never reached?

I have a module where hook_menu() was already used to process ajax calls, like this: function bizaudit_menu() { return [ 'bizaudit/ajax' => [ 'page callback' => '...
0
votes
0answers
28 views

Redirect from a path

I have a routing.yml file with a path which triggers a controller method. When the controller method finishes the operation I want to return user to the page he came from originally. I don't want to ...
0
votes
1answer
38 views

Alter existing route's output formats?

I want to alter the entity.node.canonical route so that when it is accessed using ?_format=json it will return the rendered node in JSON. So far I have created a RouteSubscriber that alters the route ...
1
vote
1answer
51 views

How to write test(s) with specific config to test custom access checks?

I have built a custom module that alters some of the User routes (view, edit, delete) to do 3 things: Forbid account editing, except a user who has 'administer users' permission Forbid account ...
0
votes
1answer
30 views

How to update route cache when saving an entity?

I have added a custom access check to the /user/{user} route: class RouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ protected function alterRoutes(RouteCollection $...
0
votes
0answers
27 views

How to check “_custom_access” for whole website and not module/path?

example: path: '/example' defaults: _controller: '\Drupal\example\Controller\ExampleController::content' requirements: _custom_access: '\Drupal\example\Controller\ExampleController::...
0
votes
0answers
34 views

Difference between adding single parameter vs adding parameter in entity?

Under custom_changes.routing.yml For argument {first_arg}, I am adding default value under defaults custom_changes.argument: path: '/arg-demo/{first_arg}' defaults: _controller: '\Drupal\...
0
votes
1answer
37 views

How to get list of all keys defined in the routing e.g path, defaults, options etc and how can we add new custom key?

route_with_two_nodes: path: '/foo/{node1}/{node2}' defaults: _controller: '\Drupal\example\Controller\ExampleController::foo' options: parameters: node1: type: entity:node ...
0
votes
1answer
46 views

Scoping an admin link to only show for certain node bundles

I have 2 node content types / bundles, A and B. each A has a relationship with multiple Bs. When on the edit page, node/%/edit, for A, I want to show a link to the list of related B so that an editor ...
0
votes
1answer
87 views

Why is $form array empty when extending FormBase or NodeForm

Why is $form not upcast with the requested bundle's fields for the default Form Mode for GET requests; and with the entities' values for other method requests? My form: namespace Drupal\tam_api\Form;...
1
vote
1answer
41 views

Get unsaved node from route parameter

What I want: In hook_media_presave I want to set a field value according to the same field on the referring node. By the referring node, I mean the node where the media entity is created through an ...
0
votes
1answer
67 views

how to extend FormBuilder::processForm from multiple API endpoints in one class

I'm trying to consolidate my form processing by entity_type, without rebuilding the forms (just using the default forms provided by Drupal. I have dynamic routes pointing to a _controller::method. I'...
0
votes
0answers
102 views

How do I redirect to an external URL in new tab by using RedirectResponse or TrustedRedirectResponse?

I need to use TrustedRedirectResponse on my site and open the external url in new tab?How can it possible in drupal 8
1
vote
2answers
27 views

Entity access controler not called from custom route

I define a custom entity named "Politician", where I set the class PoliticianAccessControl as an access handler. This is working fine for the canonical url of the entity set in the following way: ...
0
votes
0answers
47 views

Why Form Api behaves differently in route and in custom block?

I’ve encountered this issue several time and I don’t know why. I know this not so easy to reproduce but maybe someone has an explanation. I’ve built several custom modules which return datas from ...
1
vote
1answer
45 views

what happen if i have the same route as path alias?

What if I have the following route in a custom module and a path alias that is equal to the route path? mymodule.contact: path: /contact defaults: _controller: Drupal\mymodule\Controller\...
0
votes
1answer
57 views

Why isn't my controller returning AccessResult::forbidden()?

I'm working on a node access module. I've set up my logic. I can't seem to get my code to return AccessResult::forbidden(). I can't even get \dpm to run in access method. What am I doing wrong? Below ...
0
votes
0answers
61 views

An issue with multiple routes with its own twig template of custom module

First time I am creating a custom module in Drupal 8. I have some pages having only HTML markup and JS code. Assume I have 3 pages flow and user goes to 1st page (next button) -> 2nd page (next ...
0
votes
0answers
26 views

Mixing routes for Drupal and GatsbyJS

i'm planning to write an application with GatsbyJS and sourcing data from Drupal. But for some application parts i want to have access to Drupal at some routes. For example page will be reachable at ...
0
votes
1answer
63 views

How to create Dynamic Routes

I have been trying to create dynamic routes by using RouteSubscriberBase class. I know we can create dynamic routes by using slug parameter in the URL. Similar to this method ( https://befused.com/...
-1
votes
1answer
60 views

How to access all the parameters in URL without getting a “page not found” error? [closed]

I used this code in Drupal 7 can access all parameter. $items['hello'] = array( 'page callback' => 'hello_handler', 'title' => 'Hello page', 'description' ...
0
votes
1answer
143 views

Custom Page routing

I created a custom page type called 'Angular page' and a custom twig template for it which loads my angular scripts and prints the <app-root> tag. I set the page URL to /angularpage and the ...
-1
votes
1answer
70 views

Error with Event Subscriber using getRouteName()

I have a problem with event subscriber. Here is the error: The website encountered an unexpected error. Please try again later. Error: Call to a member function getRouteName() on null in Drupal\...
0
votes
1answer
54 views

How to put a link in my route title?

In my custom module amap, I have amap.routing.yml with (among others) this route: amap.distribution_inscription_many_form: path: '/amap/editPlanningMany' defaults: _form: '\Drupal\amap\Form\...
1
vote
1answer
39 views

Which of the two approaches to routing a module settings page is the best practice?

There seems to be two ways to link a route to a settings form for a module. I'm curious as to whether one is considered a better practice, and why. _controller: '\Drupal\mymodule\Controller\...
0
votes
1answer
143 views

Using parameters in routes

I am using the pathauto module to create url aliases for all user account url, so: /user/[uid] will become /u/[user:account-name]-[user:uid] which means: /user/36 will become /u/john-smith-36 In ...
0
votes
0answers
39 views

content type, local tasks and routing

So I have two content types, organisation and room. I'm using pathauto on room so the path for a room is /meet/[organisation]/[room] (based on a field in the room content type linking to the ...
1
vote
0answers
47 views

Add routing config via admin UI

I have a Drupal site with a specialised search query page that accepts about a dozen arguments as URL query parameters, most of which are optional. Simplified routing YML file looks like this: ...
0
votes
0answers
39 views

Create route with default param

I've a custom route and form, form input field(s) slightly changes based on arguments passed to it. There are only 2 possible arguments can be passed in URL. I'm using current latest version of Drupal ...
0
votes
0answers
16 views

Local task in user page to add content of specific type

i've a content type called job, i want to show a local task as a tab on user page to simply let him adding a content from there. I've created the MYMODULE.links.task.yml file in my module with this ...
0
votes
2answers
49 views

Getting 443 Forbidden Error on my custom module

I am learning drupal 8 and creating my own custom module. I have a clean localhost installation and was following some tutorials online to create a very basic "hello" for my first attempt. The issue ...
0
votes
1answer
120 views

Route Parameter Validation Problem

I have limited experience with D8 and custom routes. Current mobile video system for client takes a scheme-less url for the video like so https://example.com/mobile-video/some-video-desktop....
0
votes
0answers
15 views

How can I use full URLs for aggregated assets on a specific route?

My organization is using an external search application. The results are intended to be wrapped in a header and footer to mimic the appearance of the main website. I've created a couple of custom ...
0
votes
0answers
23 views

Create Custom Views Link with arg

its about Drupal 8, i created views with link "/admin/x" ... i want create menu in mymodule.links.menu.yml to open "/admin/x/city" i'm using in mymodule.links.menu.yml: imapping....
0
votes
0answers
31 views

Trying to send data from client (JS) to server (D8) using jQuery.ajax [duplicate]

I'm new to D8 but have some D7 experience. I'm trying to receive some JSON data from the client and process it in my module. I have successfully received (I can break on it in my debugger) the ajax ...