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

Questions tagged [routes]

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

1
vote
1answer
214 views

Possible parent values for parent of links

I am trying to create links in my Drupal 8 module, following this tutorial. So far, I have a link as follows in my module.links.menu.yml file: module.admin_settings: route_name: module.adminForm ...
0
votes
1answer
166 views

How to get the URL of an entity being created at hook_entity_insert() stage?

I'm trying to send an email "someone added content" with the URL to the entity as the message body. function MYMODULE_entity_insert(EntityInterface $entity) { if ($entity->getEntityTypeId() === '...
5
votes
2answers
294 views

Do new routes in Drupal 8 *require* a static first portion?

Using mymodule.routing.yml, I can successfully create a custom route at /foo/{bar}/{baz}. I cannot seem to do either of /{bar}/{baz} or /{bar}/foo/{baz}. It just returns 404. Why? Is there any way ...
1
vote
3answers
803 views

routing.yml for a custom form not working [closed]

I have a form I'd like to use as a standalone page, which I'm defining in a module I've called "SREvent". I have created modules/srevent/src/Form/SREventListForm.php: <?php /** * @file * ...
1
vote
1answer
471 views

Disabling language prefix for route in module

How can I disable the automatic redirect to the language prefixed url for an url defined in a routing.yml in my module? I'm developing a custom sitemap.xml module, because the Simple Sitemap Xml ...
0
votes
0answers
112 views

8 - How to set page title for certain nodes?

I've created the following codes: The first one is mymodule/mymodule.services.yml services: mymodule.route_subscriber: class: Drupal\mymodule\Routing\RouteSubscriber tags: - { name: ...
-1
votes
1answer
33 views

Missing title in template for custom route

I'm missing a title (_title) being shown on a custom route page. I wonder where i can place it in a template for it to show up. My route: bg_helper.blogs_overview: path: '/blog' defaults: ...
0
votes
1answer
418 views

Alter menu link path based on content type

I'm stumped on how to achieve this in Drupal 8 due to the removal of menu related functions. What I would like to do is check whether a menu link points to a node of content type File, and then alter ...
2
votes
1answer
242 views

Add config forms to existing admin page

Instead of creating a new route and menu: amustatuscode.config: path: '/admin/config/statuscode/config' defaults: _form: '\Drupal\amu_http_status_code_display\Form\...
1
vote
1answer
36 views

How to build a link to a field_ui form?

Given an entity type id of a fieldable entity type, a bundle name, and a view mode name, how do I construct a url to the respective field_ui form where this view mode can be edited? The patterns for ...
1
vote
2answers
235 views

What is the best way to verify controller arguments?

For example, I have a path on my site. Let it be www.mysite.com/year/{year}/month/{month}/day/{day} Could you clarify me, what is the best way to avoid getting of wrong arguments, such as year/3000/...
0
votes
0answers
25 views

Is it required to define a route while calling form through formBuilder()

Is it required to define a separate route while calling form through \Drupal::formBuilder()->getForm();
2
votes
0answers
385 views

Tell taxonomy links to use route in custom module

I have a module where I created a route /page/tag/{term} that uses a controller for modifications to how the term page is handled. The problem is that when any page displays these term links, they ...
1
vote
1answer
34 views

Is having a routing.yml file necessary?

I'm new to Drupal 8, and was curious why some modules have a *-routing.yml file, while others don't. Why is this the case? Does this mean that modules lacking in a *-routing.yml file don't have any ...
3
votes
2answers
187 views

How to prevent users (except for admin / editors) from viewing canonical page for content type?

For a certain content type, if you want most users to be able to view the content type (node bundle) when it's loaded on landing pages or on other node pages, but you don't want them to be able to ...
0
votes
1answer
19 views

Removing dozens of Routes from a collection

I am using a contrib module that is adding a local task to all entities, where I only want it to be added for Nodes. So far, I have this written to handle the problem in the short term: /** * ...
0
votes
1answer
982 views

Override specific routing from a core module

I want to stop anonymous users being able to access a specific set of routes offered by the core/forum module. specifically: forum.index: path: '/forum' defaults: _controller: '\Drupal\forum\...
0
votes
0answers
60 views

What does the method `getLinkTemplate` do in an entity type?

I am trying to debug the Access by Entity module, and it isn't generating new routes that it should be doing in its RouteSubscriber. This line here: if ($access_load = $entity_type->...
0
votes
2answers
142 views

hook_menu_alter for taxonomy vocabulary

My vocabularies machine name is vocab_ . $account_id . First Funcs: too see the user $account_id is the same with vocab.. if yes then return TRUE. function _term_account(){ global $base_url; ...
0
votes
0answers
307 views

Non-empty string as route parameter

I'm creating a search results page using the Search API. I want to set an url like this: /search/{text} How should i set up my route? It must accept any combination of characters, including non-...
0
votes
2answers
391 views

When an anonymous user hits '/user/login' route, how can I trigger an event?

I want to trigger an event when an anonymous user comes to /user/login. I made an event subscriber, but it only fires one time: namespace Drupal\mymodule\EventSubscriber; use Symfony\Component\...
2
votes
1answer
718 views

Change view & edit route or URL of Entities generated by Drupal Console

I have generated a custom entity using Drupal Console. drupal generate:entity:content However, there is one serious problem. All the default route for the various operation related to that entity ...
1
vote
1answer
24 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
1k 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 etc Thanks.
0
votes
1answer
430 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: ...
3
votes
2answers
302 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
489 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
59 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
3
votes
1answer
97 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
1answer
30 views

get routing several directories down

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
30 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
101 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
67 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
201 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
262 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
411 views

Content Entity Access Denied

I Have /** * @ContentEntityType( * id = "test_entity", * label = @Translation("label"), * bundle_label = @Translation("Testing entity type"), * handlers = { * bla... * "access" ...
1
vote
1answer
2k 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
921 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
83 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
39 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
1k 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
596 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
263 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 ...
0
votes
1answer
568 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\...
2
votes
1answer
1k 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
142 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
441 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. ...