Questions tagged [routes]

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

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 ...
2
votes
1answer
472 views

Want parent MENU_LOCAL_TASK tab to show when on a child page

I have a set of local task menu items defined in my module. This includes the following items: control => MENU_NORMAL_ITEM control/jobs => MENU_DEFAULT_LOCAL_TASK control/jobs/% => MENU_??? control/...
1
vote
0answers
27 views

what happen if i have the same route as path alias?

What if I have the following route in a custom module and a path alias that is equal to the route path? mymodule.contact: path: /contact defaults: _controller: Drupal\mymodule\Controller\...
1
vote
2answers
499 views

Print Main Menu inside a block

Very new to Drupal--trying to understand building a dynamic navigation menu for end users to handle. Is it possible to print the Main Menu inside a block I'm using for the header? e.g. <nav id="...
0
votes
1answer
481 views

is it possible to have multiple access callback for a menu item

I am trying to add access callback to already existing access callback for a menu item. For eg, path = [node/nid/edit] with access callback 'AC1'. Now is it possible for us to add another access ...
0
votes
1answer
572 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: ...
0
votes
1answer
444 views

Displaying parts of main menu in separate blocks

I need to display my main menu in separate blocks: the first sub-menu in one block, and the following two sub-menus in another block. I'm using Drupal's native menu module and also the nice menus ...
1
vote
1answer
548 views

RouteNotFoundException when trying to delete a custom entity

I am building a custom component in Drupal 8 that has an entity with child entities i.e., TeamEntity has one or more MeetEntity objects. When I navigate to the "Delete" link for a given MeetEntity, I ...
0
votes
1answer
32 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 ...
0
votes
1answer
23 views

Page not found while create custom form

I am a newbie in Drupal 8. Today I have created a custom form in Drupal 8. Here is the folder structure and here is my routing.yml resume.form: path: '/resume/myform' defaults: ...
0
votes
1answer
464 views

How to use shortcodes to insert tabs, toggles and other elements in nodes?

I would like to be able to insert certain elements (tabs, accordion toggles, tooltips etc..) and layout/formatting options (columns and layout dividers, boxes, containers etc..) in nodes using ...
3
votes
2answers
2k 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
31 views

Imported Image Style Edit Form Error

I am getting an error accessing the edit form for imported image styles. *Tested on Drupal 8.6.13 and 8.7.3 Create image style in UI. Export image style. Delete image style in UI. Import image style....
0
votes
1answer
339 views

Return Table and Form in page callback

I have a problem returning table and form in page callback at the same time it only works if one of them only returned. function _table_maps(){ $query = db_select('maps','m'); $result = $query->...
0
votes
0answers
33 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 ...
1
vote
1answer
476 views

Override theme function for menu callback

What I am looking for: I have a custom node link which, when clicked, displays a custom HTML content (option selections) in a lightbox. I need to pass an argument to the HTML content to generate the ...
0
votes
1answer
517 views

Adding class to nested UL in Drupal 7 menu

I'm creating my menu using view along with Bootstrap to create a mega menu style navigation. I'm having a problem with the nav showing expanded at times when you come to the site and or refresh. not ...
4
votes
1answer
532 views

Providing menu route parameter values from url

Suppose I have the following route in my ej.routing.yml file: ej.form.user.profile: path: '/user/{user}/ej_profile' defaults: _title: 'EJ Profile' _form: '\Drupal\ej\Form\User\ProfileForm' ...
0
votes
1answer
525 views

Config Entity list_builder controller path throws Route Does Not Exist error

I have created a custom config entity, which declares a list_builder controller to return a list of the created entities. Before creating a config entity, it renders as expected. Once I create a ...
0
votes
2answers
541 views

How to create parent child menu programatically?

I have an array like this : Array( [0] => Array( [link_title] => Level == bod [link_path] => link1 [menu_name] => parrent-child-menu [weight] => 1 [expanded] => 1 ) ) Array( ...
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
2answers
504 views

Render page callback output in another region than “content”

I am implementing hook_menu and I want to render the output of one page callback in a certain region, other than content. Is there a way of doing this?
0
votes
1answer
508 views

Permission for translating menu items via the menu config screen

I have a multi language Drupal site, Using i18n and the entity translation approach. Translating menu items from an node works well, but not all the menu items are driven by the nodes. Now as user/1, ...
1
vote
2answers
504 views

Dynamically creating menu links, through views, from a node's fields

This is my first time using this site for help but here is my issue. I have to first, Create a Menu like block based on the information in a Content type. Below every link is a text area field from ...
2
votes
1answer
488 views

Problems with active-trail within a Views-generated block

I have played with Menu Trail by Path and Menu Position, but none worked well with a Views-generated listing acting as a navigation menu. Imagine the following scenario: On the left side there is ...
3
votes
2answers
549 views

hook_menu create a URL/Menu Item

I'm trying to create a page through hook_menu so I can add my custom block with context instead. function my_module_menu() { $items['my_page'] = array( 'title' => 'my_page', '...
0
votes
1answer
41 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/...
2
votes
2answers
625 views

Overriding an entity add/edit form through alterroute

I want to create my own version of the add/edit form for an entity defined in contrib module (drupal_commerce). I assumed i'd be able to adapt the example here http://www.foreach.be/blog/how-...
1
vote
4answers
582 views

How to show sub-menu in a block in drupal 7?

I have a menu in Drupal 7 with 2 main links like home and about us, but I have 3 sub menu in about us like About us About Us 1 About Us 2 I need to show these 2 submenu in a block and show ...
0
votes
1answer
540 views

Displaying titles of collapsed menus

I'm currently converting a mock-up and I need to display four menus in a list, the first two are expanded, and I need to display both the titles and menu items, and the next two are collapsed, so I ...
0
votes
1answer
52 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' ...
1
vote
1answer
611 views

Menu Block won't display when a page has a View Block on it

I have Menu Block installed to provide some contextual menus for certain areas of a site. These generally work great. But I have a few pages where I'm adding a Views generated block to the bottom of ...
0
votes
0answers
626 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
35 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
vote
1answer
379 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 ...
-1
votes
1answer
36 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\...
13
votes
3answers
10k 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 ...
2
votes
2answers
2k views

How can I turn off Drupal redirect caching?

I have a url that would normally redirect to a specific page, however, some code is run prior to this. I am returning a RedirectResponse and it appears to be being cached. How can I force this to not ...
0
votes
1answer
738 views

How do I dynamically change the title of a menu link?

I made a menu in administration, structures, menu. I want to change the title, as it appears on the menu, of one of the links based on the gender of the currently logged in user. I have found several ...
0
votes
1answer
43 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\...
1
vote
1answer
5k views

Create a form programmatically and display result on template

I'm trying to create a simple page with a form. With the different filled fields I want to execute different EntityFieldQuery in the HOOK_form_submit. To finish I want to display the result of ...
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 ...
2
votes
1answer
679 views

Theme template.php functions after bootstrap

I'm trying to print a drupal menu outside drupal. In order to achieve this I ran the bootstrap as follows: drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); And I render my menu as follows: public static ...
1
vote
1answer
402 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:...
2
votes
2answers
1k views

How to translate the menu title?

Currently I am working on a multilingual website and have already a multilingual set-up. Now I have translated menu items and it is working great, however I also want the menu title to be translated. ...
0
votes
1answer
754 views

Function hook_menu() does not work: Callback function not found

I want to use the function hook_menu() for a custom menu item with following code: function custom_api_menu() { $items = array(); $items['new/task'] = array( 'title' => 'New task', '...
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
38 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\...