Questions tagged [routes]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
28 views

Is there a way to restrict access to a particular node?

One of my teammates created a simple page that displays links to important contents. However, since it is simple content, the page itself is restricted but the link still shows up in the main menu. I'...
1
vote
1answer
2k views

Is there a way to show all routes used?

I want to get a list (dump) of routes used? Example: /user/register /user/logout /custom/route /node/27/some-description
0
votes
1answer
644 views

How to have OutboundPathProcessorInterface change the URL of the loading page

I have a page my/topics. The page presents content based on the user's selection from another page. Having made the selection, it and other information is passed to the page via a query string: ...
2
votes
2answers
552 views

How do I define a route and controller for the home page?

A custom module called TSA contains almost all of the functionality for the /tsa subsite on my Drupal 8 multisite. I want to define a route for http://localhost/tsa/, so that I can serve up dynamic ...
0
votes
1answer
1k views

How to (truly) alter a URL in Drupal 8

I'm using OutboundPathProcessorInterface. I notice a few odd things about its behavior. In adding, for example, "/x" to the path, it works in some cases, like admin/structure, but not others, like ...
1
vote
1answer
693 views

Form submit results in “Too many redirects” error for anonymous users

I have a custom route on my site at /search. This page has a couple of forms on it (defined with FormBase). When I am logged in, the form appears to work. When I am anonymous, many many requests ...
0
votes
1answer
79 views

Route, set meta title in controller

I have a route that takes data from APIs, so I would like to set the title in the controller and not in the getTitle function because it would mean calling 2 or more times the same API
2
votes
1answer
120 views

How do I create a configuration menu with the selected section name?

I want to create a menu in the admin section that is in the sitename/admin/config path. As of now, I am doing this. Routing file custom_menu.adminmenu_section: path: '/admin/config/custommenu' ...
0
votes
0answers
33 views

get routing several directories down [duplicate]

I have a routing.yml file which has the following path: path: '/downloads/{path_dir}' it works fine when the url is /downloads/diana for example. but when the url is /downloads/diana/cast then it ...
1
vote
1answer
32 views

How can I find all the listeners or subscribers to the KernelEvents:REQUEST event?

More specifically, how could I find the subscribers performing the routing system for Drupal? We tried using ddebug_backtrace(), but I couldn't get anything.
0
votes
0answers
46 views

is it possible for content Entity to have multiple links

If I have: entity type: car_make and entity content: car_model by default: car_model will have 5 links: * links = { * "canonical" = "/admin/test/entity/{car_model}", * "add-form" = "/...
0
votes
1answer
143 views

hook_menu - setting a variable to use in page.tpl.php

I know how to use hook_preprocess_page() to add/change variables for use in page.tpl.php. For nodes, you can use menu_get_object() to load the current node and process it from there. How do I do ...
1
vote
1answer
146 views

how to debug a controller not being run

my code below results in a page not found when I browse to the path. How can I debug what is going wrong? I dont see any errors and I have cleared the cache. mymodule.content: path: '/admin/...
0
votes
1answer
288 views

Custom module is not working

I created custom module to display Hello world text in custom page. I did not install drush and composer in my windows machine as I don't have admin access. I have pasted my files below: example....
0
votes
1answer
311 views

how to setup entity access correctly?

How to setup entity access correctly? i have entity: /** * @ContentEntityType( * id = "test_entity", * bla... let me know if you need detail of this * "route_provider" = { "admin" = "...
1
vote
3answers
2k views

Pass argument to custom access callback

Is there a way to specify an argument to pass to a custom access callback, specifically an argument that isn't part of the path? Like in Drupal 7 you could do this: function mymodule_menu() { $...
0
votes
0answers
616 views

Content Entity Access Denied

I Have /** * @ContentEntityType( * id = "test_entity", * label = @Translation("label"), * bundle_label = @Translation("Testing entity type"), * handlers = { * bla... * "access" ...
4
votes
1answer
3k views

How to allow a route to a user as long as he has the good role?

Maybe this is a noob question but here goes: I have a menu a menu that contains four links. However, I need one of the items to be accessible only if the current user has "beneficiary" as role. ...
5
votes
2answers
1k views

How can I add cache context to custom menu link?

I have two routes that receive user as route parameter, and i need a menu link for every one in account menu. So I added in my *links.menu.yml client_account_links: deriver: \Drupal\my_module\...
1
vote
0answers
105 views

Redirect After Creating New Taxonomy Term

I am new to Drupal. I am trying to figure out if it is possible to redirect back to the Taxonomy page right after adding the new vocabulary term instead of being directed to the manage page of the ...
0
votes
1answer
43 views

Can I use another entity in the route to provide an entity to an entity form?

I am working on a custom content entity that I want to 'link' to a user by adding it as a tab to the user profile. Each user can have one such entity. My route is defined as follows: entity....
0
votes
1answer
2k views

how to get list of all route in routeProvider?

I have: class MyRouteProvider extends DefaultHtmlRouteProvider { public function getRoutes(EntityTypeInterface $entity_type) { $test = parent::getRoutes($entity_type); // TODO: Change the ...
1
vote
1answer
663 views

How do I hide a local task (tab) if a module is disabled?

I would like my local tasks (tabs), defined in mymodule.links.task.yml, to appear only if a certain module is enabled. If a certain module is disabled, I want the tab to be hidden. mymodule.alpha: ...
1
vote
0answers
348 views

One route, multiple controllers

How can I go around having a single route that would internally be forwarded to a controller depending on some internal logic. I've looked into dynamic routes but it doesn't help since the route is ...
1
vote
1answer
738 views

How to create a link that uses a route?

I am trying to add a link to a taxonomy landing page, like this $breadcrumbs->addLink(Link::createFromRoute($term_name,"/taxonomy/term/$tid")); but I get the following error : Symfony\Component\...
3
votes
1answer
3k views

How can I render an URL path from a custom route?

In my module.routing.yml (and using D8), I have a module_new route associated with the /module/name path. I want to render this path in my module. How can I show http://example.org/module/name on a ...
0
votes
1answer
210 views

dynamic route not updated

I have dynamic route: from this example /** * @file * Contains \Drupal\example\Routing\ExampleRoutes. */ namespace Drupal\example\Routing; use Symfony\Component\Routing\Route; use Symfony\...
0
votes
1answer
531 views

Create menu link for authenticated user programatically

So here is what I've tried in custom module dir I've created module.links.menu.yml file here is code. I want to just for authenticated user beside Content link have my custom link to access Webform. ...
1
vote
1answer
662 views

How do I create a route that is specific for a subdomain?

I'm looking to create a "subdomain" path to my custom controller running on a Drupal 8 site, with routing and hopefully without the need for an additional module. The idea is to for example have a ...
3
votes
1answer
810 views

Custom configuration forms: translation access denied

While creating custom configuration forms, I'm getting an access denied. But on the /translation page of the form only. Configuration form itself can be reached, filled and updated without problems. ...
2
votes
1answer
716 views

Get the language from route

Is there a way to get the language from a routeMatch in Drupal 8? E.g. if I do: $route_match = \Drupal::routeMatch(); Currently I can't find any language information in the returned object. It ...
4
votes
1answer
638 views

Create a path to node/add in twig

Can I use the path() function in twig to create a link to a non-node entity add form. Taking the group module as an example, if I want to create a link to the 'group/add' page in twig can I use ...
0
votes
1answer
316 views

How do I dynamically change an autocomplete route for a field depending on another field's value?

On my node edit form, I have a select field (Field A) and another taxonomy reference field (Field B). Field B is currently using "views" as a reference method to filter for the options. When the ...
5
votes
3answers
3k views

How do I correctly setup caching for my custom API routing?

I have custom module with some routes which return JSON, for instance terms of a vocabulary. routing.yml mymodule.terms: path: '/api/terms/{vid}' defaults: _controller: '\Drupal\mymodule\...
0
votes
1answer
813 views

How to add query parameters to a CacheableJsonResponse's cache?

I have an API which returns various json, like terms of a vocab, nodes of a type, with specific fields and so on. Now, in my API I am getting the requested language like so: $request = \Drupal::...
1
vote
1answer
795 views

How to get current route in the midst of a Views AJAX request

I need to conditionally pass contextual filter values to a view based on the current route and am attempting to do so in hook_views_pre_view. This is the result of using AJAX via views_infinite_scroll ...
2
votes
1answer
1k views

Defining module.links.action.yml with route parameters

How can I pass dynamically route parameters to module.links.action.yml? My code of module.links.action.yml: module.group_apply: route_name: module.group_apply title: 'Subscribe to group' ...
0
votes
1answer
29 views

hook_menu() doesn't work as expected. How can I fix that?

hook_menu() contains the following code. //案件 > インポート設定 > GMC_Subaccountの追加 $items[FEED_MANAGER_MENU_PATH.'/import/%import_id/gmc_subaccount/add'] = array( 'title' => 'GMCサブアカウントの追加', ...
0
votes
1answer
71 views

conceptual question about updating GET url

I am sorry if this question was asked before, but I am getting hard time with a concept of changing url parameters that was created by GET form in Drupal 8. Here what I have done so far and what I ...
4
votes
1answer
555 views

Providing menu route parameter values from url

Suppose I have the following route in my ej.routing.yml file: ej.form.user.profile: path: '/user/{user}/ej_profile' defaults: _title: 'EJ Profile' _form: '\Drupal\ej\Form\User\ProfileForm' ...
2
votes
0answers
56 views

Why would routes lose their aliases?

I have experienced this twice now on a Drupal 8 site. Pathauto is at its current version and Drupal is 8.2.6. What is happening is sometimes nodes 'lose' their aliases and revert back to being node/...
6
votes
1answer
5k views

How to Trigger Existing, Non-Form Ajax from JavaScript Event

I'm trying to figure out AJAX in Drupal 8. I have a custom module that works, using AJAX to change the content of a div when a link is clicked. The API says: Many different events can trigger ...
2
votes
1answer
563 views

Change the URL of a node based on parent path

So let's say I have a basic page node. I want to have this as an entity reference inside another content type - let's say an event content type. So let's say that the event content has a url like ...
1
vote
2answers
3k views

Disable caching on a route

I have a route with a parameter, e.g. /r/{app_id}. The controller extends ContainerInjectionInterface. The method either returns a render array or a new TrustedRedirectResponse. I believe I have a ...
0
votes
1answer
171 views

Creating Custom Modules tutorial doesn't work - help! [closed]

I'm trying to teach myself how to create a custom module using Drupal 8, and followed the instructions on their website at this Drupal.org documentation page I created the folders, hello_world.info....
1
vote
1answer
555 views

Alternate of using “delivery callback”

$items['mymodule/%user'] = array( 'title' => 'My Module', 'page callback' => 'mymodule', 'page arguments' => array(1), 'access arguments' => array('access user profiles'), 'type' ...
0
votes
2answers
3k views

How do I call a controller method from a twig template and passing arguments to it?

I know I can pass variables to templates using render arrays. $theme = 'block-AcademicDisplay'; return array( '#theme' => $theme, '#content' => $content, '#url' => urlencode($url), ...
2
votes
2answers
3k views

how to create a route with query string?

I have tried a few things and I cannot manage to make this working. My route is the following. amu_hal.publicationsPerYear: path: '/publications/{year}' defaults: _controller: '\Drupal\...
0
votes
0answers
73 views

route not working when using encoded url as upcast parameter

my route amu_hal.publicationsPerYear: path: '/publications/{year}/{url}' defaults: _controller: '\Drupal\amu_hal\Controller\AmuHalController::publicationPerYear' _title:...
1
vote
1answer
430 views

Convert view route parameter to entity

Task: Create a view with link to it displayed among node tabs (View, Edit, etc.). Solution: Create a view with page display and set its path to "node/%node/foo". Issue: When the page "node/%node/foo"...