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

Why is $form array empty when extending FormBase or NodeForm

Why is $form not upcast with the requested bundle's fields for the default Form Mode for GET requests; and with the entities' values for other method requests? My form: namespace Drupal\tam_api\Form;...
1
vote
1answer
41 views

Get unsaved node from route parameter

What I want: In hook_media_presave I want to set a field value according to the same field on the referring node. By the referring node, I mean the node where the media entity is created through an ...
2
votes
3answers
667 views

taxonomy menu select list with redirect when a menu item is selected

I'd like to have a taxonomy drop-down list like the one in www.1mobile.com. When I select an term, it should go to the respective page, showing products concerning with selected term. I tried Custom ...
1
vote
1answer
74 views

How can I change Menus depending upon domains (url name)?

I want to change main menu items depending upon domain and sub domains url in a single site. I could have done it easily with roles, but issue w.r.t anonymous users. How would I show or not certain ...
3
votes
3answers
2k views

Adding menu with description like mega menu [closed]

I would like to create a menu with a description of the menu like megamenu. My menu looks like the following model: How can I create this?
1
vote
1answer
396 views

OG menu default links are not adding up

I am using og_menu 7.x-3.x-dev I am trying to create some default links to the og menu, but links are not adding.With a new group node its creating the og menu but the default links are not coming.Do ...
-1
votes
2answers
724 views

Retrieve argument in hook_menu() item url

On my custom module, I defined the following hook_menu() function. function motel_events_menu() { $items['ajax/pastevents/%'] = array( 'title' => 'Get Past Events', 'page ...
1
vote
1answer
39 views

Set default menu link as default menu?

I have sub menu of Main menu. I need to set 2nd sub menu as default menu, so when user visit a site 2nd sub menu should open.
3
votes
2answers
2k views

hook_menu() wildcard problem

I can't get the wildcard from a hook_menu to pass it to a callback function Here is what I have: function spin_menu() { $items = array(); $items['spin/login/%'] = array( 'title' =&...
1
vote
1answer
44 views

Customizing menu link output (add badge)

I am new to drupal. I want to customize menu link <ul class="nav nav-tabs sub-menu"><li class="menu-1308 first active"><a href="/" class="active">Top</a></li> <li ...
0
votes
1answer
64 views

How to alter main_menu for logged user?

I would like to alter/change structure of main menu links (programmatically!) for logged in users. What is the simplest way to do this?
2
votes
1answer
713 views

Add Meta tags and Title on hook_menu “page callback” [closed]

How to add Meta and Title tags to the document head on hook_menu "page callback"? Drupal 7
1
vote
0answers
57 views

Using active trail as url path

I would like to use the active trail menu as url path by altering pathauto? Can this be performed?
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
7
votes
5answers
14k views

How to correct disappearing admin menu?

I use the Admin Menu module for my projects. In my Drupal 7 and Pressflow 7 instances, it randomly shows only some menu items. At first, I thought I could correct this by clearing menu cache. When I ...
0
votes
1answer
67 views

how to extend FormBuilder::processForm from multiple API endpoints in one class

I'm trying to consolidate my form processing by entity_type, without rebuilding the forms (just using the default forms provided by Drupal. I have dynamic routes pointing to a _controller::method. I'...
4
votes
3answers
3k views

How do I use variables in links.task.yml?

I have a local links.task.yml file to display the tab for the node data , But it seems to have a problem passing argument to the path . As you can see i am extending the node's basic fetaures like ...
3
votes
2answers
2k 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 ...
1
vote
2answers
27 views

Entity access controler not called from custom route

I define a custom entity named "Politician", where I set the class PoliticianAccessControl as an access handler. This is working fine for the canonical url of the entity set in the following way: ...
0
votes
0answers
47 views

Why Form Api behaves differently in route and in custom block?

I’ve encountered this issue several time and I don’t know why. I know this not so easy to reproduce but maybe someone has an explanation. I’ve built several custom modules which return datas from ...
11
votes
4answers
7k views

Increase memory limit doesn't help in Fatal error: Allowed memory size of …/modules/views/views.module on line 416

I've switched from Drupal 7.14 to 7.15 three weeks ago and therefore, I'm encountering a series of very sophisticated (for me) memory limit errors. Those errors occur any time I'm trying to clear ...
0
votes
1answer
56 views

Why isn't my controller returning AccessResult::forbidden()?

I'm working on a node access module. I've set up my logic. I can't seem to get my code to return AccessResult::forbidden(). I can't even get \dpm to run in access method. What am I doing wrong? Below ...
3
votes
2answers
3k views

How do I implement the equivalent of hook_url_inbound_alter()?

I'm working on a module which will resolve URLs to entities by altering inbound URLs so that if they contain an entity ID with following pattern "-{entity_id}" user will be redirected to correct URL. ...
2
votes
2answers
1k views

How do I build Breadcrumbs for a certain node?

In a node preprocess hook I am getting breadcrumbs for the currently viewed node by doing the following: $vars['breadcrumb'] = Drupal::service('breadcrumb') ->build(Drupal::routeMatch())->...
0
votes
0answers
61 views

An issue with multiple routes with its own twig template of custom module

First time I am creating a custom module in Drupal 8. I have some pages having only HTML markup and JS code. Assume I have 3 pages flow and user goes to 1st page (next button) -> 2nd page (next ...
0
votes
0answers
26 views

Mixing routes for Drupal and GatsbyJS

i'm planning to write an application with GatsbyJS and sourcing data from Drupal. But for some application parts i want to have access to Drupal at some routes. For example page will be reachable at ...
0
votes
1answer
63 views

How to create Dynamic Routes

I have been trying to create dynamic routes by using RouteSubscriberBase class. I know we can create dynamic routes by using slug parameter in the URL. Similar to this method ( https://befused.com/...
-1
votes
1answer
60 views

How to access all the parameters in URL without getting a “page not found” error? [closed]

I used this code in Drupal 7 can access all parameter. $items['hello'] = array( 'page callback' => 'hello_handler', 'title' => 'Hello page', 'description' ...
0
votes
0answers
636 views

How to pass a url as a hook menu argument

I need to send a url as a variable in path e.g. 2 arguments. The 2nd argument would need to be a url so http://www.blah.com. However, at the moment even if I use urlencode (which produces /http%3A%...
0
votes
1answer
141 views

Custom Page routing

I created a custom page type called 'Angular page' and a custom twig template for it which loads my angular scripts and prints the <app-root> tag. I set the page URL to /angularpage and the ...
-1
votes
1answer
70 views

Error with Event Subscriber using getRouteName()

I have a problem with event subscriber. Here is the error: The website encountered an unexpected error. Please try again later. Error: Call to a member function getRouteName() on null in Drupal\...
14
votes
3answers
12k views

How do I alter the route defined by another module?

In other words, what is the Drupl 8 equivalent of hook_menu_alter()? Drupal 8 still uses hook_menu(), but for what I can see, the information returned by the hook is different from what the hook ...
0
votes
1answer
54 views

How to put a link in my route title?

In my custom module amap, I have amap.routing.yml with (among others) this route: amap.distribution_inscription_many_form: path: '/amap/editPlanningMany' defaults: _form: '\Drupal\amap\Form\...
6
votes
3answers
1k views

Disable the /blog route

I'm using Drupal 6.16. I would like to permanently disable the /blog path (and all its sub-paths, but not the Blog module. Is this possible?
2
votes
1answer
3k views

Access denied on hello world custom module

Drupal 8 installed in Debian VPS server. Some installed themes do not work, some do. When tried to creat a simple 'Hello World' module,as described in a beginners book for drupal, installing of the ...
1
vote
1answer
566 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:...
3
votes
2answers
1k views

Wildcard for routes

How can I pass the complete path arguments to a route defined in a mymodule.routing.yml file? example_archive.content_archiv: path: '/examplearchiv/{myvalue}' defaults: _controller: '\Drupal\...
1
vote
1answer
39 views

Which of the two approaches to routing a module settings page is the best practice?

There seems to be two ways to link a route to a settings form for a module. I'm curious as to whether one is considered a better practice, and why. _controller: '\Drupal\mymodule\Controller\...
0
votes
1answer
142 views

Using parameters in routes

I am using the pathauto module to create url aliases for all user account url, so: /user/[uid] will become /u/[user:account-name]-[user:uid] which means: /user/36 will become /u/john-smith-36 In ...
0
votes
0answers
38 views

content type, local tasks and routing

So I have two content types, organisation and room. I'm using pathauto on room so the path for a room is /meet/[organisation]/[room] (based on a field in the room content type linking to the ...
1
vote
0answers
47 views

Add routing config via admin UI

I have a Drupal site with a specialised search query page that accepts about a dozen arguments as URL query parameters, most of which are optional. Simplified routing YML file looks like this: ...
0
votes
0answers
39 views

Create route with default param

I've a custom route and form, form input field(s) slightly changes based on arguments passed to it. There are only 2 possible arguments can be passed in URL. I'm using current latest version of Drupal ...
1
vote
1answer
2k views

How to force a menu parent link to be non-clickable?

I want the parent link in the menu to not be clickable. As a path is mandatory, I have created a blank node, and in my module I substitute the link by a "#" char. I used custom code in module because ...
0
votes
0answers
16 views

Local task in user page to add content of specific type

i've a content type called job, i want to show a local task as a tab on user page to simply let him adding a content from there. I've created the MYMODULE.links.task.yml file in my module with this ...
10
votes
3answers
7k views

If you update a routes file in Drupal 8 how do you clear the cache?

Having worked with Drupal 7 since its launch, I'm learning Drupal 8. At the moment I'm finding that whenever I change anything I have to do drush cache-rebuild to get things working again. On my VPS ...
0
votes
2answers
49 views

Getting 443 Forbidden Error on my custom module

I am learning drupal 8 and creating my own custom module. I have a clean localhost installation and was following some tutorials online to create a very basic "hello" for my first attempt. The issue ...
0
votes
1answer
119 views

Route Parameter Validation Problem

I have limited experience with D8 and custom routes. Current mobile video system for client takes a scheme-less url for the video like so https://example.com/mobile-video/some-video-desktop....
0
votes
2answers
2k views

Unable to create an admin menu link

I am trying to create a menu link in Drupal 8. I am following this document: https://api.drupal.org/api/drupal/core!includes!menu.inc/group/menu/8 My module name is twitter_pull and I was able to ...
0
votes
0answers
15 views

How can I use full URLs for aggregated assets on a specific route?

My organization is using an external search application. The results are intended to be wrapped in a header and footer to mimic the appearance of the main website. I've created a couple of custom ...
0
votes
0answers
23 views

Create Custom Views Link with arg

its about Drupal 8, i created views with link "/admin/x" ... i want create menu in mymodule.links.menu.yml to open "/admin/x/city" i'm using in mymodule.links.menu.yml: imapping....