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

How do I modify a custom entity delete form?

I have a custom entity "Possession" that I created that has a non-standard edit form route to help facilitate a decending url structure. The routing for the edit form looks like this: entity....
2
votes
2answers
487 views

how to restrict access in routing.yml based on roles

I know how I to restrict access in the routing.yml file based on permissions, but how can I do it based on roles? This is how to do it by permissions: requirements: _permission: 'access ...
3
votes
0answers
63 views

Detail page route gives error

In my_module.routing.yml my_module.detail: path: '/module/{id}' defaults: _controller: '\Drupal\module\Controller\DetailController::view' requirements: _access: 'TRUE' In template twig ...
0
votes
1answer
18 views

Externally Requesting Browser Test Created URL for Relaxed Replication

I am trying to write a browser test for for a workspace replication via relaxed web services using the multiversion, replication and relaxed modules. For this purpose I set up an external Drupal ...
3
votes
1answer
87 views

Why is my form only redirected sometimes?

I want to have a user register, and be redirected to a node create form. Here's how I'm doing it thus far. The setup I have a route, my_module.register that is handled by MyController::register(). ...
0
votes
1answer
194 views

Hooks and routes not working at all

I have a module called hello_world. I have a hello_world.info.yml file in drupal/web/modules/custom/hello_world whose content is the following. name: Hello World description: Hello World module type:...
0
votes
2answers
37 views

Custom username paths?

I want to be able to create paths like this: /guy1 /guy2 /guy3 It's easy enough if I want /profile/guy1 ... then I can just do this: gg_profile.viewUserProfile: path: '/profile/{username}' ...
3
votes
3answers
335 views

Can I conditionally hide a route (e.g. action / local task)

Consider an action button on a custom entity's canonical page: mymodule.actions.yml: entity.item.action: route_name: entity.item.action title: 'Do something' appears_on: - entity.item....
0
votes
1answer
23 views

Can access arguments only be specified once for all sub-routes?

For example: I would start off by setting this. $items['admin'] = array( 'access arguments' => array('administer users'), 'type' => MENU_NORMAL_ITEM, ); But the anytime after I use admin in ...
0
votes
1answer
39 views

Change routing behaviour for non-existent entities

For my custom entity type called item, I would like to set up routes such that the path: /item/{item} views the entity as normal, if it exists if it doesn't exists, redirects to the create form The ...
3
votes
1answer
35 views

8 - Is It Possible To Create Routes Through The Admin

Question: Is there a way for users to create routes in the admin? Issue: I have a bunch of nodes and tax terms that are being used in Views but no where else. They shouldn't be accessible to the ...
0
votes
3answers
202 views

PHP Warning SplObjectStorage::offsetExists() expects parameter 1 to be object, null given

Updating to 8.5.1 today from 8.4.5, and after a successful update, I start getting the following warnings on every page: Warning: SplObjectStorage::offsetExists() expects parameter 1 to be object, ...
0
votes
0answers
72 views

Access denied to admin on custom module

I get access denied to admin user in my custom module. This is my routing yml file: operatordb: path: operator-database defaults: _form: \Drupal\operatordb\Form\OperaDBForm _title: '...
4
votes
1answer
813 views

How do I define a Route with multiple different paths?

Does Drupal's routing system support a regular expression or other means for multiple route paths? I have a route that I would like to be able to hit from two different endpoints, /api/v1/foo and /api/...
0
votes
1answer
311 views

How to add a default controller to the <front> route?

Is it possible to add a default controller to the '<front>' route? There's no default controller defined in system.routing.yml. I'm trying to get a handle on it by using the following code: &...
2
votes
2answers
1k views

Alter existing route to a different route for a specific content type node using RouteSubscriber

I want to modify node edit of a specific content type node to a different route . Eg : suppose i have a node edit page route as entity.node.edit_form (core feature) . And now i want to change this ...
0
votes
0answers
12 views

Drupal 8 Panels customization

I am trying to customize Panels and Panels IPE modules functionality in Drupal 8. Basically, while loading a block in a panel page through Panels IPE, I don't want to display the "Title" (along with ...
0
votes
1answer
32 views

routing.yml file doesn't work

I'm working on an existing Drupal 8 site. I'm changing anything in routing.yml. In a routing.yml file I have the following. user_profile_update.callback: path: '/user-update' defaults: ...
0
votes
1answer
31 views

Throw entity field value from submission to route path?

I have created two entities and I want to connect them by route. my edit route is: entity.entity_two.edit_form: path: '/property/configuration/communication/{entity_one}/variant/{entity_two}/edit'...
0
votes
3answers
51 views

How do I make the page created from my module visible only to anonymous users?

I programatically created a page using the following code. /** * Implements hook_menu(). */ function page_prog_menu() { $items['page_prog/custom'] = array( 'title' => 'My Custom page', ...
4
votes
1answer
406 views

Define node array id as parameter in routing

Is that possible to send somehow an array of nids and automatically convert it into and array of nodes? Something like: custom.custom_nodes: path: '/custom/{nodes}' defaults: _form: '\Drupal\...
1
vote
0answers
34 views

Use a route with an id to mimic a node type but pull from a third party source?

Is it possible in Drupal 8 to create a route like /events/{id} with a controller, and in that controller make a call to a third party API to fetch data and then send that data to a template? It ...
0
votes
1answer
150 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
197 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
80 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
72 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
259 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
189 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
83 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
217 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
604 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
60 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: '...
0
votes
1answer
316 views

Create Custom page with custom blocks in Drupal 8

I just wanted to create a custom page with lots of custom block. For example an offer page, the offer contains multiple block with three Fields like name, image, description. The block must be dynamic ...
-1
votes
1answer
293 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/...
3
votes
1answer
340 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
90 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
46 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 ...
1
vote
2answers
1k 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
237 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
202 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
206 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
45 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
52 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
83 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
73 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
85 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
779 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
543 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
142 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
226 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\...