Questions tagged [routes]

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

Filter by
Sorted by
Tagged with
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
875 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 ...
0
votes
2answers
901 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
967 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' ...
0
votes
2answers
888 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 ...
0
votes
1answer
70 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 ...
2
votes
2answers
796 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). ...
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 ...
2
votes
2answers
757 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 ...
0
votes
0answers
28 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 ...
0
votes
1answer
2k 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
0answers
42 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
37 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 ...
2
votes
1answer
342 views

Jump Menu Style Dropdown To External Links

I'm attempting to create a jump menu of links to external websites, and I would like to be able to order the links within this menu differently depending on the organic group of the current user ...
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
14 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
28 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
81 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
22 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....
0
votes
0answers
30 views

Trying to send data from client (JS) to server (D8) using jQuery.ajax [duplicate]

I'm new to D8 but have some D7 experience. I'm trying to receive some JSON data from the client and process it in my module. I have successfully received (I can break on it in my debugger) the ajax ...
0
votes
0answers
14 views

Hide “empty” menu parents

I have the following scenario: I have a sidebar that contains my mainmenu. Menuparents are linked to route:<nolink>. Those parents can be expanded using superfish (accordion). When a user has ...
0
votes
2answers
3k views

How do I call a controller method from a twig template and passing arguments to it?

I know I can pass variables to templates using render arrays. $theme = 'block-AcademicDisplay'; return array( '#theme' => $theme, '#content' => $content, '#url' => urlencode($url), ...
2
votes
2answers
3k views

how to create a route with query string?

I have tried a few things and I cannot manage to make this working. My route is the following. amu_hal.publicationsPerYear: path: '/publications/{year}' defaults: _controller: '\Drupal\...
0
votes
1answer
26 views

Pass argument when overriding controller in RouteSubscriber

I am having the issue of overriding the default taxonomy controller /taxonomy/term/{tid}. I have created my own controller which takes {tid} as a parameter and I want to use it instead, so I overrode ...
2
votes
2answers
1k views
0
votes
1answer
522 views

Create menu link for authenticated user programatically

So here is what I've tried in custom module dir I've created module.links.menu.yml file here is code. I want to just for authenticated user beside Content link have my custom link to access Webform. ...
2
votes
2answers
108 views

How to hide a menu from <front> page?

The main menu comes with 5 items. How can I hide one items from the < front > page, i.e. 4 items are shown on front page, 5 items are shown on other pages?
1
vote
1answer
45 views

Passing Argument in Drupal 6 not working [closed]

Im very new to drupal. Recently I have started learning drupal 6 with reference project done by my friend. It was having so many bugs and fixed most of from the list. Still Im not getting how hook ...
1
vote
1answer
168 views

hook_menu wildcard auto-loader for webform submission?

In hook_menu() array keys, you can specificy wildcard tokens to autoload certain objects, such as %node to get the node object. Is there a wildcard autoloader token for webform submissions? Some ...
1
vote
2answers
273 views

hook_menu() items created in a custom module don't retain the active-trail of the parent tab

So I have a custom module that is adding 3 menu items (a main tab, and 2 sub-tabs). When navigating to the main tab (url: /casereports) the default_local_task is displayed as expected and both menu ...
14
votes
2answers
2k views

If two modules both defined the same menu path in 'hook_menu', which one Drupal will choose?

For example, "moduleone" defines the path 'admin/hello', which output print_moduleone_stuff(). /** * Implements hook_menu() */ function moduleone_menu() { $items['admin/hello'] = array( '...
0
votes
1answer
24 views

Why does the title callback of /user produce the title for /user/register?

I'm a bit puzzled why the title callback of /user produces the title for /user/register and /user/password. When I set the title callback of /user, I see this affects the title of /user/register and /...
0
votes
1answer
314 views

Custom content entity route or url alias

I'm not certain if I'm over-complicating something or just missing something or other. Essentially, and in addition to a separate admin view of my custom entities, I want to assign a URL to them at ...
0
votes
0answers
51 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, ...
9
votes
2answers
8k views

How to test if current page is an admin page?

At some point I started using the following code to test if current page is an admin page: $route = \Drupal::routeMatch()->getRouteObject(); $is_admin = \Drupal::service('router.admin_context'...
0
votes
1answer
172 views

Return data from WebformHandler to Controller

I created WebformHandler where I need to get data entered in the form on submit. It's something like this: <?php namespace Drupal\xxx\Plugin\WebformHandler; use Drupal\Core\Form\...
12
votes
6answers
9k views

How to redirect an anonymous user to the login form after a 403 error?

I want to redirect an anonymous user to the login form if such user encounters a 403 error. I have created event subscriber and this is my code, but I end up on loop on the current page. /** * ...
1
vote
3answers
4k views

How to output from custom module without rest of theme

What the proper method of outputting a page from your module without any additional theming beyond your template, for example to make a page that is good for printing? I've tried a few different ...
3
votes
2answers
867 views

Routing match everything

i want to match in a route a 'random' URL with a random sub path, fox example: /example/1/a/b/c /example/c3/s ... i implement this route in my .routing.yml file modulo.validator: path: '/example/...
1
vote
1answer
745 views

How to get current route in the midst of a Views AJAX request

I need to conditionally pass contextual filter values to a view based on the current route and am attempting to do so in hook_views_pre_view. This is the result of using AJAX via views_infinite_scroll ...
0
votes
1answer
36 views

how do 404 pages work?

How does the 404 page you can define in /admin/config/system/site-information work? I found Drupal\system\Controller\Http4xxController->on404(), but how does that display whatever path I definied in ...
2
votes
2answers
170 views

How to add “publish content” to a node view tab

I'm developping a website where I'm asked to add a tab "Publish content" next to the Edit tab. I was told to use the hook_menu, but so far i didn't succeed in showing the tab. Here is what I have ...
0
votes
1answer
562 views

get last element in URL(menu item) generated by hook_menu

I have created a URL/menu item via hook_menu, and in the proprocess_html I'd like to get my item (last element in the URL) (/test) without using arg(0). I can do it in PHP but I was wondering how it ...
2
votes
1answer
704 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
786 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
132 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 ...