Questions tagged [routes]

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

0
votes
0answers
34 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
0answers
27 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
32 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
1answer
23 views

Page not found while create custom form

I am a newbie in Drupal 8. Today I have created a custom form in Drupal 8. Here is the folder structure and here is my routing.yml resume.form: path: '/resume/myform' defaults: ...
0
votes
0answers
33 views

Imported Image Style Edit Form Error [on hold]

I am getting an error accessing the edit form for imported image styles. *Tested on Drupal 8.6.13 and 8.7.3 Create image style in UI. Export image style. Delete image style in UI. Import image style....
0
votes
0answers
34 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
41 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/...
0
votes
1answer
52 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
35 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
36 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
43 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
38 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\...
1
vote
1answer
58 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
26 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
42 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
37 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
11 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
21 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
58 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
21 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
27 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 ...
0
votes
0answers
14 views

Hide “empty” menu parents

I have the following scenario: I have a sidebar that contains my mainmenu. Menuparents are linked to route:<nolink>. Those parents can be expanded using superfish (accordion). When a user has ...
0
votes
1answer
17 views

Pass argument when overriding controller in RouteSubscriber

I am having the issue of overriding the default taxonomy controller /taxonomy/term/{tid}. I have created my own controller which takes {tid} as a parameter and I want to use it instead, so I overrode ...
0
votes
1answer
21 views

Template suggestion don't work with a custom menu link (custom route)

In a module I have created a custom link by creating a custom route inside the mymodule.routing.file.yml and the mymodule.links.menu.yml file. In my theme.theme file I have defined a hook_page_alter ...
0
votes
1answer
24 views

Why does the title callback of /user produce the title for /user/register?

I'm a bit puzzled why the title callback of /user produces the title for /user/register and /user/password. When I set the title callback of /user, I see this affects the title of /user/register and /...
0
votes
1answer
177 views

Custom content entity route or url alias

I'm not certain if I'm over-complicating something or just missing something or other. Essentially, and in addition to a separate admin view of my custom entities, I want to assign a URL to them at ...
0
votes
1answer
119 views

Return data from WebformHandler to Controller

I created WebformHandler where I need to get data entered in the form on submit. It's something like this: <?php namespace Drupal\xxx\Plugin\WebformHandler; use Drupal\Core\Form\...
0
votes
1answer
34 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
98 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
51 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
37 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
52 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
53 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
398 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
216 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
39 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
327 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
86 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
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
62 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
171 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
75 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
104 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
30 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
61 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
182 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 ...