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

How to view external url from a route file Drupal 8

How to create a route that opens an external file? As an example I have a xml file in my S3 bucket. (http://bucket_url/file.xml). I need to create a route to open that file from my website. Like if ...
0
votes
1answer
277 views

Multiple aliases per node (and active trail)

Our site is split down the middle for tenants and landlords. But we have content the is the same for both such as "how to report antisocial behaviour". User would normally navigate something like "...
1
vote
1answer
119 views

Show pages with a specific template when user is logged-in

I would like to know if there is a way to show an existing node with a custom template if user is logged-in or has a specific role. I have tried with a custom module route. custom_module....
0
votes
1answer
90 views

Dynamic route's controller method not firing

I'm trying to use the Background Image module, but there seems to be a problem with the dynamic route it registers for generating CSS. I've been debugging it, but I have run into a wall. It's ...
1
vote
1answer
536 views

Routing for controller with multilingual enabled

On my Drupal 8 multilingual project, I have made a custom controller which create a basic page, but I can't figure out which parameter I must use in the routing. Is this _locale? This is the ...
0
votes
1answer
284 views

Custom module access denied [closed]

I just have followed two tutorials on Youtube, https://www.youtube.com/watch?v=79zYcIoheCc&t=43s and https://www.youtube.com/watch?v=SAP9clnOf9E&t=8s. The result was a "You are not authorized ...
0
votes
1answer
112 views

How do I programmatically add a new search page to the search page list?

I have been able to successfully create a search plugin for a custom module, which allows users to search for my custom entity by name. After creating this file, I have to enable it by visiting /admin/...
-1
votes
1answer
311 views

Passing parameters to route

So currently i am passing some params to a form via the route path as so: my_module.action: path: '/status/{action}/{id}' defaults: _form: '\Drupal\my_module\Form\MyForm' requirements: ...
1
vote
1answer
818 views

How do I set the tab title?

How do I set the title of the tab from a controller in Drupal 8? This is the code I am using: Controller class myController extends ControllerBase { public function node($nId) { $...
5
votes
1answer
93 views

Why is this extremely simple form not getting an upcast entity from its route?

I have a my_job_board.routing.yml: my_job_board.user_register_form: path: '/my-job-board/register/{user_role}' defaults: _form: '\Drupal\my_job_board\Form\UserRegisterForm' _title: '...
-1
votes
1answer
562 views

change an add entity route to a custom route in order to not use admin theme

I will start off by saying i have already studied these posts, to no avail: Overriding an entity add/edit form through alterroute How to load my Entity in Entity form https://www.drupal.org/docs/8/...
4
votes
1answer
549 views

Improve D8 performance to access a custom REST controller

Context I'm currently upgrading a site from Drupal 7 to Drupal 8. In the D7 version, there was a custom "proxy" module which served back-end services. Requests starting with a /service prefix, such ...
3
votes
1answer
96 views

Routes node.add.CONTENT_TYPE are no longer available starting from Drupal 8.4 in hook_menu_links_discovered_alter()?

If you implement the hook_menu_links_discovered_alter() hook in Drupal 8.3 you have access to change the links with a code like this: /** * Implements hook_menu_links_discovered_alter(). */ ...
0
votes
1answer
54 views

Node only accesible by path alias

I was wondering if it's possible to make nodes without path alias not accessible. By this I mean that visiting /node/$nid/ users will not be able to see its content, but if that node has an path alias ...
2
votes
2answers
2k views

How to force a redirect (override the destination query string in the URL)

I have a custom form submit callback to redirect users to a specific page: function MYMODULE_authfrontpageredirect_callback(array &$form, FormStateInterface &$form_state) { $url = \Drupal::...
1
vote
1answer
318 views

How to set a default controller if no other routes match

I my project I would like to have a default route or controller that handles any request that does not match any available route. For example on requesting /abcd it now returns 404 as there is route ...
0
votes
0answers
328 views

Translatable paths with parameters in routing.yml

Given the following routing.yml: my_module.my_route: path: 'some-path-in-english/{slug}' defaults: _controller: '\Drupal\my_module\Controller\MyController::__invoke' requirements:...
1
vote
0answers
308 views

Routing with optional parameters for webform is just giving page not found

I created my webform to accept parameters via a standard $_GET and this works fine but is quite unsecure I am told and should rather use clean URL's via Drupal 8 built in Routing. As such I set up a ...
1
vote
1answer
53 views

Can a Event Service be coupled to a route

I have created a custom service and have hooked into the "event_subscriber" via tags in my custom service.yml demo_api.exception_handler_subscriber: class: Drupal\demo_api\Response\Handler ...
0
votes
0answers
60 views

How do I find the route to extend a form?

I'm using the Content Moderation module in 8.4 and I want to override the /core/modules/content+moderation/src/Form/EntityModerationForm.php. I copied EntityModerationForm.php to /modules/MYMODULE/...
0
votes
2answers
157 views

Route that renders a node has title of route rather than node title

I have a route that takes a wildcard $product and then loads a default node that is stored in config. This is working (i.e. the node is rendered on that path) but instead of the node title it is ...
1
vote
2answers
88 views

Defining hook_menu() paths for specific base URLs

I have a multi-site; each site has its own database but they all share the same codebase. I would like to know if there is a way to define hook_menu() paths at specific base URLs. Being it a ...
-1
votes
2answers
88 views

Full urls to internal pages logging users out

I have a website with a private area for authenticated users only. I have some custom routing to control user access and it generally all works fine, however, I have run in to a problem I am not sure ...
3
votes
1answer
1k views

How can i pass JavaScript variables back to PHP Controller in Drupal 8

I have a custom module which uses a Javascript library called Bootstrap Table. Among other things, this library allows me to create tables with clickable rows. Currently, I can pass variables from the ...
0
votes
1answer
788 views

Taxonomy term route name?

I am trying to make a custom taxonomy breadcrumbs based the code from this question: Drupal 8 How to do a custom taxonomy breadcrumb? This line adds a new breadcrumb for the home page: $breadcrumb-&...
1
vote
1answer
174 views

Is it possible to have a dynamic route as configure module page?

I installed the SEO Checklist module and when I go the search in the Extend (admin/modules) page the module Configure page I don't see it, so I go the the module issue an create a new issue Add link ...
1
vote
1answer
392 views

Access denied to my route, created in module.routing.yml

I'm having a hard time trying to figure out why my custom route is returning a 403 status. My routing.yml file: lightbox.content: path: '/lightbox/content' defaults: _controller: '\Drupal\...
1
vote
2answers
56 views

hook_menu() and collapsable menu items with wildcard

I've defined a few routes with hook_menu(), and added these routes to a menu with nesting. This works fine for all static routes, but for any route with a wildcard the 'active-trail' does (...
1
vote
1answer
459 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
374 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
384 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
1k 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
702 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
149 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
35 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
568 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
379 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
39 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
386 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
521 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
36 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 ...
2
votes
2answers
351 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
26 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: /** * ...
3
votes
1answer
2k 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
76 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
160 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
437 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
507 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
818 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 ...