Questions tagged [routes]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
656 views

How do I direct link a view to a taxonomy menu?

I have created a vocabulary with over a hundred terms on three levels (parent/child/child) and used Taxonomy Menu to create a custom menu. Selecting a menu item brings up a default menu page with ...
2
votes
1answer
3k views

Correct way to use hook_menu_alter

What is the correct way of using hook_menu_later. I did this in my module to redirect (see also redirect in hook_init makes body text disappear): function MYMODULE_menu_alter(&$items) { $items[...
2
votes
1answer
112 views

Why are some menus created for authenticated users not displaying? [closed]

Whatever menus created for authenticated user, some menus are displaying and some created menus are not displaying. If I login as admin, it shows all created menus and its child menus. Why is this?
2
votes
1answer
1k views

Custom module embedding existing node form

I have the following content types: event signup I'm dealing with my_singnup module, for which I wish to: allow user to add signup content (same as core node/add/signup) using signup/event/%...
1
vote
1answer
61 views

Most maintainable way to make page with one top half and alternative bottom halves selected by tabs?

I want to make a page which has one top part, a row of two or more horizontal tabs beneath it, and alternative bottom parts which appear beneath that and can be selected by clicking on the tabs. For ...
1
vote
1answer
2k views

Translate routing and menu titles

I've made two yml files, for both routing and menu item: Route: tester_helper.products_controller_overview: path: '/assortment' defaults: _controller: '\Drupal\tester_helper\Controller\...
1
vote
1answer
918 views

How to add query parameters to a CacheableJsonResponse's cache?

I have an API which returns various json, like terms of a vocab, nodes of a type, with specific fields and so on. Now, in my API I am getting the requested language like so: $request = \Drupal::...
1
vote
1answer
923 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\-...
1
vote
1answer
215 views

Default entity ID for _entity_view in routing.yml

I've a custom content entity (created using Config pages module) which is used as a welcome screen / dashboard. Privileged super editors can edit those content entities, normal editors can only view ...
1
vote
1answer
179 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
849 views

How to create a link that uses a route?

I am trying to add a link to a taxonomy landing page, like this $breadcrumbs->addLink(Link::createFromRoute($term_name,"/taxonomy/term/$tid")); but I get the following error : Symfony\Component\...
1
vote
3answers
2k views

I can't add links to any of my menu

I can't add links to any of my menus. I go to the menu, click on add link, and fill all the required data; I get the message, "Your configuration has been saved." It doesn't seem it is what it is ...
1
vote
2answers
768 views

How to show the node delete tab and put a view in it?

I would like to show a 'Delete' tab near the 'View' and 'Edit' tabs in the node page and insert a custom warning message and a view in it. If I create a view tab page with path /node/%/delete it works ...
1
vote
2answers
3k views

How to enable menu link when creating a new node?

I try to enable the menu link programmatically, here is how I do it: function create_menu_link() { $node = new stdClass(); $node->type = 'mytype'; node_object_prepare($node); $...
1
vote
4answers
3k views

Custom classes for menu links

How can I add custom classes for links into main menu in Drupal 8. This is template for my main menu called menu--main.html.twig {% import _self as menus %} {{ menus.menu_links(items, attributes, 0) }...
1
vote
2answers
2k views

How to use hook_menu_link_alter() on taxonomy term view?

When viewing a taxonomy term, I want to change the 'Edit' link (in the admin tabs) to say 'Edit this term' instead. In taxonomy.module, the menu item is defined like this: function taxonomy_menu() { ...
1
vote
1answer
588 views

How to delete system menu links

I want to remove the "My Account" and "Log out" menu links, as I've incorporated those into other parts of the page. Now, I'm a Drupal novice so if I'm making rookie mistakes here go easy! What I've ...
1
vote
1answer
36 views

Send Mail to Specific Roles

I need to send Emails to site users with specific role like "Administrator". This is achievable using view on any action like "After saving new content".. etc.. But i want to send emails on one menu ...
1
vote
2answers
775 views

translate menu item using entity translation

I am kind of confused and really need some guidance Is there a way to translate menu items using entity translation?(One item for all languages) Thanks
1
vote
1answer
1k views

Filter category taxonomy with tabs

i have a node which is of content type "Album", they all have categories defined by terms , and i want the user to be able to choose which category he want to filter by but with tabs instead of a ...
1
vote
2answers
4k views

Views menu tabs with a dynamic view

I have built a DYNAMIC VIEW to display city data, broken out as tabs on the page -- it is a modified verion of the taxonomy term page view. It uses view menu tabs for this segregation, and Taxonomy ...
1
vote
2answers
2k views

Show children of a Taxonomy Term

I make use of the view: "taxonomy term". Is there an easy way to also show the children of a term, next to the nodes beloging to this term? Example: Cars - Volvo --- Family_cars --- Sports_cars - ...
1
vote
1answer
51 views

How do I record hook_menu() access statistics

I have a standard menu hook function in a custom module which links to example.com/foo/bar, how do I record access statistics for this page?
1
vote
2answers
2k views

Active main menu link

I need to set an item in the main menu as active even though I'm using separate sub menu blocks. What is the best way to do this? Due to particular styling I cannot just put them under the Category ...
1
vote
1answer
1k views

How to fetch submenu items for current page?

My site nav is all in a single menu: main-menu, eg: Home About Director Name 1 Director Name 2 Contact My site navigation bar comprises two horizontal strips: the upper one lists all top-level ...
1
vote
4answers
299 views

How do I redirect a user role on login (Drupal 6)?

So I want to create a new user role (already done) and redirect them to a certain page (and use a certain menu) when they log in. I'm not seeing any specific place to do this under roles or ...
1
vote
1answer
889 views

How to display instances of a field (field collection) in tabs?

I have a content type with a field which has a number of instances (actually, it's a Field Collection with a vimeo embed and a text field). I would like to have each instance of the field to be shown ...
1
vote
1answer
1k views

How to style a programmatically created page with a template?

I'm struggling with understanding theming pages with templates. I'm stuck with creating a new template for a programmatically created page. I have a module that shows a download page for a file. The ...
1
vote
1answer
735 views

Remove link from active page in menu

I need the active page in my menu not to be a link. So let's say I'm on the services page, I need my menu structure to look like this: <ul class="menu"> <li class="first leaf"><a ...
1
vote
2answers
304 views

Add .active class when certain view is executed using hook_menu

I have a view that is not related with a menu but I need to add .active class to an element of this menu when the view is shown. How can I alter the element adding a class active?
1
vote
1answer
938 views

Creating a menu while categorizing my products

Hello I am developing an e-commerce website with drupal commerce(commerce kickstart) everything seems great.I have imported my products and I have tested it and I made my catalog like the video on ...
1
vote
1answer
3k views

Return both a form and content in a menu callback

I have the following code. function mymodule_menu() { $items = array(); $items['mymodules/page'] = array( 'title' => t('my module settings'), 'description' => t('change values here'...
1
vote
1answer
141 views

Cannot get theme_links__system_main_menu($variables) to fire now matter what

i've added the code below to my theme's template.php file. i've cleared the cache too. but this just isn't firing no matter what. i'm not getting any errors either. anyone have any experience with ...
1
vote
3answers
2k views

Entity form additional arguments

I have normal Drupal8 Content entity, and I'd like to set up some additional arguments for the entity form builder. Ie I have entity form path like so: /tilaus/uusi/{tilaus_type} and I'd like to add ...
1
vote
1answer
1k views

Child navigation sidebar or drop-down navigation displaying child items

I have a 'basic page' which is a parent and is provided a menu link. This page has several children (subpages). How would I display the subpages for each nav item either in the following cases? Drop-...
1
vote
1answer
1k views

What would be the correct way of adding a link to existing path into admin menu?

What is the correct way to add a link to a menu? I am using Drupal 7 and admin menu module. I would like to add a link to the content menu item so it would be Content Content Add Content ...
1
vote
2answers
1k views

in drupal 7, how to add user pic and name to the user menu when logged in?

In drupal 7, there are default blocks such as user menu block and login block, the user menu block are especially working for the logged in user while login block are working for non logged in user. ...
1
vote
1answer
3k views

Proper use of hook_menu_breadcrumb_alter()

I have a situation where I need to mess with a breadcrumb on a page and insert some items in the middle. In my instance drupal_set_breadcrumb() can't be used, so I need to implement a ...
0
votes
2answers
2k views

How to create submenu based on content type and taxonomy?

I would like to create a submenu that lists items based on content type and taxonomy. Here's the setup. Shop for a Car [Basic Page] Financing Options for cars [Basic Page] loan 1 [Content ...
0
votes
1answer
130 views

Compare two menu tree objects

I'm trying to add custom css class to a particular menu, same task mentioned here. I moved a little further and found this article. So I put following code in template.php: <?php function ...
0
votes
1answer
177 views

How to put a node in a menu using an URL parameter?

While creating a new node, I'd like to pass a parameter in the URL: node/add/page?plid=123 in order to put the newly created node in this menu item as its child. I tried to hook_form_alter() the node ...
0
votes
1answer
42 views

Alter existing route's output formats?

I want to alter the entity.node.canonical route so that when it is accessed using ?_format=json it will return the rendered node in JSON. So far I have created a RouteSubscriber that alters the route ...
0
votes
1answer
1k views

why does internationalization menu i18n_menu translate but never localizes?

I have a menu set to : Translate and Localize. Menu items with language will allow translations. Menu items without language will be localized. And I have include menu items that are "language ...
0
votes
2answers
269 views

Drupal installation profile: menu_link_save() doesn't work for “import” path

In my installation profile, I am trying to add a menu link for the /import path (from feed_import module). menu_link_save() works for all my menu paths with the exception of /import. Anyone have ideas ...
0
votes
1answer
96 views

Custom view mode issues

My goal is to switch between different view modes based on the node path (pattern). In my case, the patterns would be: dossier/node-alias => default template dossier/node-alias/cover => cover ...
0
votes
4answers
365 views

Can we use the same path for a different route?

Are we allowed to use the same path for two different routes? For example, can I use the following code? function mymodule_menu() { $items['myUrl/dboperation'] = array( 'title' => 'some ...
0
votes
2answers
1k views

Why my hook_menu does not work?

I have this code in the module cleanetica_advanced. function cleanetica_advanced_menu() { $items['ajax/content/%'] = array( 'page callback' => 'cleanetica_advanced_ajax_load', 'page ...
0
votes
1answer
575 views

Add class to menu link href tag?

I know that using hook_menu_link I can add classes to the <li> tags but I need to add a class to the <a> tags within the <li> of a menu. I've looked and can't find a way. Any ideas?...
0
votes
1answer
620 views

Is it possible to add second horizontal Menu below Main Menu?

I use "user menu" on top, for user related links. I use "main menu", in reaching my main contents of site. I need one more horizontal menu below the "main menu". So second priority links will be ...
0
votes
0answers
1k views

Drupal: $_POST and MENU_CALLBACK. How works?

I've read this and this but nothing is working for me I'd like to create a menu like this $items['login'] = array( 'page callback' => 'mymodule_login', 'access arguments' => array('access ...