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.

2
votes
1answer
568 views

Get the language from route

Is there a way to get the language from a routeMatch in Drupal 8? E.g. if I do: $route_match = \Drupal::routeMatch(); Currently I can't find any language information in the returned object. It ...
1
vote
1answer
606 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 ...
1
vote
3answers
563 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 ...
1
vote
1answer
627 views

Is it possible to include a forward slash in a route dynamic property?

Is it possible to include forward slashes in routing parameters? // routing.yml mymodule.route path: '/mymodule/{param}' defaults: path: '' requirements path: '[A-Za-z0-9\-...
0
votes
1answer
624 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
26 views

How to upcast webform submission in custom routes resp. controller?

Using this route: confirm: path: '/node/{node}/submission/{webform_submission}/confirm' defaults: _controller: '\Drupal\mymodule\Controller\MymoduleController::confirm' _title: 'Confirm ...
2
votes
1answer
677 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
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 ...
0
votes
1answer
749 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', '...
2
votes
2answers
949 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
795 views

How to organize categories and subcategories of products in menus?

I have product content type that I want to display in a menu. Every product belongs to subcategory that belongs to main category, for example: Computers: PC: - product 1 - product 2 ...
2
votes
2answers
772 views

Can we have multliple routing.yml files in a single module?

I have more than 50 menus which I need to create custom. as per the module structure, we need to create routing.yml in root folder. but i want to do something like this below myModule - ...
0
votes
0answers
44 views

Splitting routing.yml in multiple files [duplicate]

I have a my_module.routing.yml file and because of I have multi entity in my module its too big and not pretty. Is there any way to split it for each entity and include them in one file like symfony, ...
4
votes
2answers
943 views

Show menu link descriptions for a custom navigation menu

I have the following navigation, displayed in page.tpl.php: theme('links', array('links' => menu_navigation_links('menu-site-navigation'))); There are four navigation elements that show up. I ...
0
votes
2answers
835 views

Problem with menu position module

I have a menu like this: In the first sidebar you see the main menu with links. The second sidebar is a block that is visible on pages that begin with stocklijst/. The link in the first sidebar ...
2
votes
2answers
775 views

Remove links from the menu tabs

How can I remove the some links from the Tab, when we are login as a particular user. Please see the below picture. I want to remove the tab Items maked in red rectangle (deny access to this link). ...
0
votes
2answers
883 views

Creating Primary Sub menu's programmatically

I want to display the latest 10 nodes of node type 'ABC' as a sub menu link under my primary menu. Are there any modules for Drupal 6 to help me achieve it. I have created a view which gives me a ...
2
votes
1answer
739 views

Defining module.links.action.yml with route parameters

How can I pass dynamically route parameters to module.links.action.yml? My code of module.links.action.yml: module.group_apply: route_name: module.group_apply title: 'Subscribe to group' ...
2
votes
2answers
718 views

form_set_error() redirects to raw ajax response page

I have a page with a simple view. Above the view there is a menu link that when clicked loads a node form with a required file field. The form is fetched and loaded using ajax_commands into a div on ...
3
votes
2answers
1k views

Cannot access Administration > People page

I cannot access the People page. There is no error message. If I click on People in the menu bar, the Administration home page is shown. The other Administration pages are accessible. Similarly, ...
7
votes
3answers
1k views

How to use URL parameter and page callbacks for tab menus correctly?

I'm using Drupal 6 and I'm trying to display two tab (menus) on a page that has the URL /vehicle_info. Both pages that the tabs link to should take a node's nid as parameter. My current code looks as ...
1
vote
1answer
1k views

How to add a tabbed menu on group main page (panel)?

I managed to get panels working with og 7.x-2.1 following: - http://modulesunraveled.com/organic-groups/part-3-organic-groups-layout - http://www.initsix.co.uk/organic-groups-panels-and-views-drupal-7 ...
0
votes
1answer
1k views

Trying to get fullPage.js implemented, but how to add data-attributes?

This is such a great script called fullPage.js I managed to load the js file and css file and even with the Void Menu Module, managed to call anchor links, but I'm struggling with the data ...
1
vote
3answers
2k views

Pass argument to custom access callback

Is there a way to specify an argument to pass to a custom access callback, specifically an argument that isn't part of the path? Like in Drupal 7 you could do this: function mymodule_menu() { $...
1
vote
1answer
919 views

Disable menu cache for hook_menu() implementation

There is a way to disable the menu cache ? Context Drupal 7 I have a custom module that implements hook_menu(). The link is showing up only if a view have results. It's working. The problem is ...
1
vote
2answers
28 views

How do I add an anchor attribute to a route?

I've created a route: regions.taxonomy_term.edit_form_header: path: '/taxonomy/term/{taxonomy_term}/edit' defaults: _entity_form: 'taxonomy_term.default' _title: 'Edit term' options: ...
1
vote
3answers
803 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 * ...
5
votes
2answers
2k views

How to set required POST parameters for routes

With GET method we can do something like this example.user path: 'example/{user}' defaults: _controller: '\Drupal\example\Controller\ExampleController::content' requirements: ...
6
votes
1answer
172 views

How can I override a module's file via hook_menu_alter()?

I have the following code in my hook_menu_alter(). <?php function bonus_menu_alter(&$items) { if (!empty($items['things'])){ $items['things']['title'] = t("New title"); $items['...
3
votes
0answers
44 views

When a path is associated to more routes, which route is used?

How does Drupal 8 decide which route to use, if there are two routes defined in Drupal 8 via routing.yml that lead to the same path? Of course this sounds like a stupid idea or like a mistake in code ...
0
votes
1answer
54 views

Link field title from entity/route

I have a Drupal link field configured to allow both internal and external links and have the title field enabled, but optional. I want users to be able to reference internal entities without having ...
0
votes
1answer
34 views

How to force 403 or 404 on specific route

I have made a custom form to create nodes for a specific content type. Due to that, I want to throw a 403 or 404 on the admin page that creates new node. The route I mean is 'node/add/'. I guess in ...
0
votes
0answers
35 views

Assign a controller to all book pages

I am trying to build a module that checks if user session set in all pages of a certain book. if the session is not set it will be set. I am using a sso system so the user data will come from there, ...
-1
votes
0answers
64 views

Block disappears unless I refresh route and link cache

I have a submenu based on the main navigation menu system. This Plugin Block builds the submenu on every page. The links of course change based on the route. Every hour around the same time, the ...
1
vote
1answer
76 views

How to redirect programmatically inside a module to an external url? [closed]

I am trying to redirect to a page after I unset a session. I read this article but I am pretty new to Drupal module building. Here this amazing guy says to do the comming thing: If you know that ...
1
vote
2answers
220 views

Using menus anywhere on page - how to stop them expanding by default when not used in menu region ( e.g. in a block or panel)?

I am trying this with superfish but the menu options are expanded by default. What would I need to do to get it to behave like it does in a menu (i.e. collapsed by default). I want to use the menu ...
5
votes
5answers
13k views

How do I modify /user to a custom URL?

I have some small Drupal 7 sites that don't require me to log in all the times, and there are no users. I would like to change the user login path to something else to deter bots targeting Drupal ...
3
votes
1answer
81 views

How to redirect user page to front page for specific roles

I want to redirect every users page to front page? like if user page url is /user/97 then it redirect to front page if user is not administrator. I want user page inaccessible to other users but only ...
1
vote
1answer
75 views

Disable user login, register and password reset

I am working on a Drupal 8 site that for all intents and purposes will be used as a company intranet. I'm also using the Social Auth Google module to allow only company-registered GSuite accounts to ...
4
votes
1answer
64 views

Get route name from path with wildcard

we've wanted to implement a policy to consider some URLs as whitelist, I've provided a config form to admin to enter whitelist Urls, separated by newline, it must support * ( wildcard). sample urls ...
0
votes
3answers
201 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
1answer
987 views

hook_menu_local_tasks_alter for specific tab

I've tried with my custom module to implement hook_menu_local_tasks_alter, but I'm not sure how can I edit specific tab. Here's my example code: <?php function ...
1
vote
1answer
31 views

Set access restriction for baseroute

Let's say I have the following in example.links.task.yml from a contributed module: example.view: title: 'View' base_route: 'entity.example.canonical' route_name: 'entity.example....
1
vote
2answers
397 views

Handling external authentication with routing.yml

I am building a new page (general use of "page", not literally referring to the node type) in my Drupal site that should only be accessible to members that have a certain permission. I have defined ...
3
votes
1answer
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. ...
0
votes
2answers
26 views

Missing argument 1 for hook_menu()

I'm getting this error in my custom module. [warning] Missing argument 1 for signin_menu(), called in /public_html/includes/menu.inc on line 2813 and defined signin.module:2 here is my code to ...
1
vote
2answers
83 views

Can I programmatically inject a route parameter?

In my projects I often have some special node (types), for which I'm creating custom admin routes and custom edit forms. E.g. I've got a restaurant homepage offering daily lunch specials. For ease of ...
7
votes
3answers
2k views

Slashes in single route parameter or other ways to handle a menu tail with dynamic number of params

According to the Symfony documentation, a route defined as below should trigger the specified controller for both /hello/bob and /hello/bob/bobby: _hello: path: /hello/{names} defaults: { ...
0
votes
0answers
28 views

Is _access: 'TRUE' mandatory for a public route?

I want a route to be accesed by everyone (logged in or not). I removed the requirements and still I was seeing Access Denied. It worked only when I put _access: 'TRUE'. Why is this mandatory? Should ...
3
votes
1answer
3k views

How to get the Route object from an URI?

If I have a Url object, or even a simple string representation of path such as /node/2, how can I get the full Route object?