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

How can I have default field values for the node add form as arguments in the URL?

I have a path in drupal 6, which allow me to add new content with 2 fields completed. For example, path node/add/my_content_type/4/6 means that I am on page /node/add/my_content_type, and first field ...
0
votes
0answers
38 views

How do I convert URL parameters to lowercase?

We have a routing.yml file in Drupal 8 which contains the following lines. testmodule.res: path: '/subject/{node}' defaults: _controller: '\Drupal\testmodule\Controller\resController::res' ...
0
votes
2answers
31 views

How do I override an entity view controller?

I am trying to override the entity view controller for a commerce product view, so that I can redirect the user based on certain conditions. I am trying to do this through the RouteSubscriber::...
0
votes
1answer
41 views

How to write custom access for a route which redirects the user to another route if a condition is true

If I visit example.route.one and certain conditions are fulfilled I want to redirect it to example.route.two OR else access should be allowed. How Can I achieve this? I tried writing the redirection ...
1
vote
2answers
51 views

Change the path used by a route dynamically

Taxonomy terms have a canonical path of /taxonomy/term/{taxonomy_term} by default, which displays a View with content tagged with that term. For certain taxonomies I would like to use a different view,...
3
votes
1answer
58 views

If multiple routes match a path pattern, how can I tell which one would be used?

If multiple routes are returned by something like the following: $route_provider = \Drupal::service('router.route_provider'); $found_routes = $route_provider->getRoutesByPattern('collection/%...
0
votes
1answer
68 views

Dynamically change the “access denied page” title and body

This is not a question about changing or preprocessing the twig template of the 403 page. I have a controller with an access function called by the _custom_access key of my route. In some circumstance,...
3
votes
1answer
44 views

Creating an API via module routing files that includes csrf verification headers

I am working on migrating a custom API from D7 to D8 and am doing so by using module routing. I have a routing.yml file that looks like so: ytp_user.api.login: path: "/api/v1/user/login" ...
0
votes
1answer
89 views

How to create custom node edit form [closed]

protected function alterRoutes(RouteCollection $collection) { if($route = $collection->get('entity.node.edit_form')) { $route->setDefault('_entity_form', '\Drupal\alerts\Form\...
0
votes
1answer
36 views

Bearer Token in url is not parsed by route

I Installed Drupal 9.1.0 on a VPS running on Ubuntu 20.4 and using Nginx 1.18.0, with Composer 2.0.8. I installed two modules (Token and Devel) and a theme (Barrio) using Composer. I can enable the ...
0
votes
1answer
54 views

Is there a way to get the controller class from a Request object or any other service class?

My controller class holds some not-so-easy logic to receive some data from a route parameter I need in a block plugin. As this block will only be rendered on this specific route, I would like to ...
0
votes
1answer
57 views

How do I create dynamic routes where the changing part is at the beginning of the path?

I need to create custom module routes like the following. /ireland-dummy-page (IE) /uk-dummy-page (UK) /dummy-page (global) How can I write the route paths for this scenario? Do I want to write ...
0
votes
0answers
27 views

Route to Url with contextual filters [duplicate]

I'm looking for a way to convert a route to an Url with contextual filters added. I can do it manually and it works, but I still think there should be a better, "Drupalish" way to do it. ...
1
vote
1answer
84 views

Alter existing 'Log In' route so URL includes request_uri as query string

I am trying to alter the existing 'Log In' URL so that it points to a certain location and also includes the REQUEST_URI as a query string that is not encoded. How do I do this? Based on this article,...
4
votes
1answer
117 views

How can I exclude certain routes from maintenance mode?

I am trying to make certain routes exempt from maintenance mode by adding the option _maintenance_access to the route and setting it to TRUE. I think (although I'm not 100%) that this works because in ...
1
vote
1answer
61 views

EventSubscriber returning correct content but status code is 404

As the title says, content is being returned correctly but the status code is 404. I have checked the .htaccess file and the Apache config file as well. All seems to be fine. I have the following in ...
1
vote
1answer
49 views

How can I programmatically get various common user profile related URLs?

I'd like to get the following URLs in Drupal 8: /user/register /user/login /logout /user I already know I can use \Drupal::service('path.current')->getPath() to get the current path. I want to ...
0
votes
1answer
52 views

Altering existing route for translation overview page ie: entity.node.content_translation_overview

I have followed this documentation page : https://www.drupal.org/docs/drupal-apis/routing-system/altering-existing-routes-and-adding-new-routes-based-on-dynamic-ones in attempt to alter access of ...
0
votes
0answers
84 views

Unable to access page when using RouteSubscriber::alterRoutes() to override display for path

Because of a need to be able to combine elements from two different entities - a node and a Commerce product - in one page, I am attempting to implement my own custom controller and override the built ...
1
vote
2answers
278 views

Add custom access check to user page

I would like to add an additional access condition to viewing user pages like user/1. I looked at the following guidelines, but have not succeeded in coming up with a solution. https://www.drupal.org/...
1
vote
1answer
49 views

How can I avoid to return HTML markup for access denied? [duplicate]

I've developed a custom controller that serves as a simple endpoint, POST method. This controller has custom access control. Custom access is done by looking for a header in the HTTP request, by ...
0
votes
0answers
22 views

Access Denied when visiting my custom route

I have a custom module with machine name "mymodule". The mymodule.info.yml file looks like this: name: My module type: module description: 'My first drupal module' core: 8.x Then I have a ...
1
vote
0answers
93 views

Programmatic menu link for a view with contextual filter and no parameters in the path

Related question (my question is when contextual filters are NOT in the path): Generate menu links for a view with contextual filter and parameters in the path In mymodule.links.menu.yml I have ...
0
votes
0answers
48 views

How to limit access to a group page to the group administrator?

I created a custom module to create a /group/ID/tasks page https://www.drupal.org/project/group How to limit access to this page to the group administrator ? If the current user is administrator of ...
1
vote
2answers
391 views

How can I allow the current user to only see their own page?

I created a page in a custom module. I want only the current user to access this page on their behalf. For example, I am using it with ID 51. If I go to : /user/51/tasks I can see this page. If I go ...
0
votes
2answers
23 views

How to determine the route for the add node page of a custom entity type?

I have a node type question that I want users to be able to create rapidly. So, after adding a question, I want them to be redirected to /node/add/question to immediately do it again. This is my code ...
0
votes
1answer
43 views

Why do I get an error related to a controller when I created a custom module?

I created custom module following the Creating a custom module on Drupal tutorial. The teacher of this tutorial demonstrated how you can create a custom module that displays on the page Hello world. ...
0
votes
0answers
53 views

What is the difference between access method in controller and custom access check

I am trying to create a module with custom access checks. I would like to know what additional features does implementing AccessInterface provide. For example I can check access within the ...
0
votes
2answers
46 views

I'm getting a page not found error when trying to visit my custom form

This is the form that I created using Drupal 8: namespace \Drupal\lookup\Form\lookupForm; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; class lookupform extends FormBase { ...
1
vote
2answers
50 views

How to hide Forums from anonymous users?

I installed Forum module. So, I have 'Forums' link in 'Tools' menu corresponding to the path /forum defined in forum.routing.yml in which access is defined by _permission: 'access content'. In my site,...
0
votes
2answers
95 views

Routing path with Entity Reference field

I'm working on a custom module (my_module) which provides some functionality to a specific paragraph type (my_paragraph) created from the user interface. In my routing file, I have the following ...
0
votes
1answer
20 views

“Route ”ctf.content“ does not exist” when installing custom module

I tried writing my own copy of the skeleton module from https://github.com/sidharrell/D8HWexample.git modules/custom/hello_world, but I thought I'd start by changing the module name and using "ctf" ...
0
votes
0answers
29 views

Callback function for module menu can't be called from another file

I have a module that uses the hook_menu to create an endpoint. It is set up like: my_api.module function my_api_menu() { $items = array(); $items['api/v1/users/test/create-test-users'] = array( ...
0
votes
1answer
71 views

How to temporarily replace Drupal with static HTML pages?

I'm a JavaScript dev with no Drupal experience. I'm working with a church to redesign their Drupal site after their dev moved on without leaving any notes/documentation/etc. In the meantime, I'd like ...
1
vote
2answers
158 views

How to change Taxonomy admin page title?

I simply need to change the title on the (Drupal 8.8.4) administrative page which lists the existing vocabularies. As far as I know/read, the routing.yml should be modified, shouldn't it? (Is only ...
0
votes
1answer
38 views

Link doesn't appear in configuration

I'm a Drupal 8 newbie writing my first module. I have a functioning yet basic module to learn from. What I'm working on now is for it to get a value from a configuration page. If I go directly to the ...
0
votes
1answer
50 views

How can you get the route name/path of groups?

I am new to Drupal 8. I am working on groups module and want to assign different themes to different groups.So i need route name of groups. how to find route name of groups. Thanks in advance. /** ...
0
votes
0answers
47 views

What causes “Page Not Found” messages with a “null” path as the log message, even when the page is displayed correctly?

Once every four or five pages I visit, I get "Page not found" messages in my log, even though the page is found and displays properly. The errors suggest part of the page path is null. For example, ...
0
votes
2answers
49 views

Creating a route with a form and some content

i have created a route with a form: amu_404_redirect_import.admin: path: '/admin/config/amu_404_redirect_import/upload' defaults: _form: '\Drupal\amu_404_redirect_import\Form\...
1
vote
0answers
47 views

Create a route that redirects users to a path via parameter

I'm working on a custom module that needs to act as a mediator between a third party service and this Drupal site to manipulate some parameters. I've created a route: my_module.process_redirect: ...
0
votes
2answers
59 views

A custom route to an entity form will not pass the entity

I want a custom route to the normal user form. So, I've added an entry to the routing file that directs my custom route to the canonical form of the User entities: my_profile_form: path: '/user/{...
0
votes
0answers
45 views

Adding “.xml” at the end of custom route path

I am trying to create custom route which will look like a xml file like this example.com/my/custom/path.xml and I am getting NGINX 404, it won't even goes to Drupal. I tried to research but I could ...
0
votes
1answer
76 views

Explicitly passing argument to local action for access check

I'm using the group module, and in a custom module I'm trying to create a local task that will bring you directly to the create page for a particular group content type. My goal is to skip the create ...
0
votes
1answer
57 views

Disable cache on base url for redirecting unauthenticated users

I am trying to redirect unauthenticated users. So anytime an unauthenticated user tries to get to the base url, redirect them to an external url. Currently works, but continues to redirect to the ...
0
votes
1answer
127 views

How to route dynamic routes to a single node while keeping the urls?

I have a node node/1 with the path alias /path. What I want is for /path/* to always behave like you went to /path, but not change the url. So going to /path/test?something=1 should behave identically ...
2
votes
2answers
251 views

Write complex access control in a reusable way

We deal with nodes representing humans with two important properties: mother and father. Your parents as well as your aunts and uncles should get extra permissions, like to see you in a certain view ...
0
votes
0answers
43 views

How to create local task links for referenced entities on a node? [duplicate]

I have a content type, which has three reference fields to three different content types. I want to create secondary task links to those referenced entities. Let's say that I have a Product content ...
0
votes
0answers
49 views

Change system.404 path dynamically based on context

I have a site that makes use of the groups module to denote various locations all with their own content. I'd like to give the ability to programmatically alter the system.404 path depending on the ...
1
vote
2answers
39 views

How to add /admin/people as a tab to a custom menu?

In a custom module (association), I ceated views that are accessible thru tabs: The paths are defined in the views; Adhérents et personnes -> /association (this one is also defined as a menu item) ...
0
votes
1answer
96 views

Alter Existing Route - Bypass/override entity permission

I added a custom access check to a JSON API endpoint so that only users who provide a token can POST/PATCH updates on a media endpoint. I followed this documentation in order to alter an existing ...

1
2 3 4 5
46