Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [routes]

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

0
votes
0answers
21 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
12 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
19 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
18 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
12 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
14 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
20 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
47 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
66 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
31 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
39 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
49 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, ...
1
vote
2answers
31 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
49 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
45 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
36 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
182 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
111 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
32 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
153 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
42 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
47 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
111 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
45 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
68 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
25 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
52 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
133 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
258 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
66 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
69 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
46 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
26 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
687 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
118 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
94 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
71 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
41 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
75 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
270 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
198 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
29 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
248 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
141 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
103 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
120 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,...