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
6k views

How to display a block with menu child items programmatically?

I need to create block with a list of links menu child items (only first level) of a given menu like this: Item 1 Item 2 Item 3 With this code I can have the menu items but I don't know how to ...
2
votes
1answer
653 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
111 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
664 views

How to solve a situation where two or more routes with different controllers point to the same path ?

For example, we have two routes, which points to the same path. And each route has its own controller. For example, I have defined a route with controller, which has a path "node/1", whereas a node ...
1
vote
3answers
1k 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
172 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
171 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
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
740 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
1answer
824 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
59 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
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
1answer
35 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
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
2answers
303 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
2answers
757 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
780 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 ...
1
vote
1answer
724 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
1answer
582 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
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
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
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
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
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
767 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
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
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
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
298 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
886 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
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
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
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
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
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 ...
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
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
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 ...
0
votes
1answer
63 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'...
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
814 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::...
0
votes
1answer
619 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
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
1answer
95 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
359 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
1answer
644 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
176 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
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
556 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
2answers
157 views

Route that renders a node has title of route rather than node title

I have a route that takes a wildcard $product and then loads a default node that is stored in config. This is working (i.e. the node is rendered on that path) but instead of the node title it is ...