Questions tagged [routes]

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

Filter by
Sorted by
Tagged with
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 ...
7
votes
2answers
4k views

How to show a menu item for anonymous users only?

I want to show a "Join Now" tab on the main menu for anonymous users only. In the past I used Menu per Role module which does exactly that. Since it's only one tab I would rather use 5 or 10 lines ...
4
votes
3answers
2k views

Get title from Route

I am trying to print out a few links on a custom page template. I would like to use the title and url from each route. I am trying to print out the title from the route. I know I can get the url ...
3
votes
2answers
1k views

How do I redirect a taxonomy menu item to another path?

I have a taxonomy menu, and I want to redirect the page request from taxonomy/term/% to a custom path using a page callback function. How can I use a function to cause the redirect?
2
votes
2answers
669 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-...
2
votes
2answers
2k views

Is it possible to change the tab order of MENU_LOCAL_TASK items on a given page?

I have created a couple MENU_LOCAL_TASK items for my advanced search page in Drupal 6, but they appear at the end of the tab list on the far right. I would like my new items to appear first in the ...
2
votes
3answers
2k views

Move user profiles under a menu item

In Drupal 7, currently when I go to a user profile, the breadcrumbs go as follows: "Home > username." I have a People section as part of my main navigation, so I would like the breadcrumbs to behave ...
2
votes
4answers
11k views

How do I append a unique menu ID to the menu?

I'm using Drupal 7 and I want to append a unique ID to specific menus. My search result gives me the way to change the item of the menu, but I want to change the menu itself. Is there a way to do ...
1
vote
1answer
1k views

My horizontal navigation menu disappeared

I can't be specific which event might have caused this to happen. Too much could have happened between me noticing the problem and the first time the problem could have occurred. Here's what I'ved ...
1
vote
1answer
187 views

Secondary & Tertiary links next to Parent links

How can I print expandable secondary and tertiary links to the right of the parent? For mobile, the secondary and tertiary links will need to stack below the parent links. Below is an example of what ...
0
votes
1answer
86 views

Menu in Drupal8

I am currently using below code to generate routes: foreach($this->hardcopyEntityManager->getHardcopyEntities() as $entity_type => $entity_definition) { $route = new Route( "...
0
votes
3answers
4k views

Menu local tasks and hook preprocess

I just want to remove a secondary menu local task from a preprocess function such as function mymodule_preprocess_menu_local_tasks(&$vars, $hooks) { $vars['secondary'] = ''; } I'm using D7, ...
11
votes
2answers
29k views

How to theme a menu block?

I have created a custom menu (lets call it "mynav") and in my theme I've created a template specifically for it (block--menu--menu-mynav.tpl.php) which contains: <div id="mynav" class="<?php ...
14
votes
1answer
18k views

create tabs with hook_menu() for custom module

since two hours im trying to create tabs in my custom modules backend. I've tried severals suggestions but couldn't get any of them to work. this is my current hook_menu() : function ...
24
votes
1answer
3k views

Why are routing files filled with underscores?

What is the deal with all the parameters with, and without, a prefixed underscore character? Where does Drupal decide how to process these parameters? Was this concept introduced from Symfony, or is ...
15
votes
4answers
23k views

Advanced menu theming in Drupal 7

I've cruised around the web and it is not at all obvious how to theme custom menus. I've looked for hours and have not found one single post that illustrates the process, from start to finish, of ...
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 ...
8
votes
1answer
7k views

Replacing menu items with images

I'm looking for a way to display a menu items as images (with rollover) rather than the usual text links. I found the module Menu Icons, but as the name implies, it's designed to place the icon next ...
7
votes
2answers
17k views

Pass arguments using hook_menu

I would build a confirmation screen. So I initialized the path in the hook_menu as it should be but for some reason, the argument $node isn't send with the function... What am I doing wrong? This is ...
5
votes
3answers
9k views

Add a class to main menu links

I've searched and found variations of this question but I've never found an answer that seemed to work. I need to add a class to the <li> elements, currently the main menu is rendered like this: ...
2
votes
2answers
3k views

hook_preprocess_page: “node_load() + node_page_view()” versus “%node + node_page_view()”

A basic node (nid "123") exists and a module registered two paths using hook_menu: first/%node second Both page callbacks use node_page_view($node) to display a fullpage view of the node, except ...
5
votes
6answers
12k views

How can I add relative path to a pdf file link in drupal menu

I have created menu link for a pdf file. I can use a full path like "http://website/sites/all/myfiles/file.pdf", but if I try to put a relative link such as "sites/all/myfiles/file.pdf" it does not ...
4
votes
1answer
986 views

Using a node editing form on a page that not a node edit page

I have created a menu item, as reported below. I have taken the form ID from the page source (form id=listorious-list-power-100-node-form) but when I go to the specified URL, I get the following error:...
4
votes
4answers
5k views

User picture and name in user menu

I would like to achieve what Acquia did on https://dev.twitter.com/. When you sign in, you can see the user picture and the user name in the right end of the menu bar and that is what I need. I made ...
4
votes
5answers
8k views

Post the same menu as two different blocks?

I have a menu called main-menu. I want to post it twice as a block: one block with a main-menu in the header, and one block with a main-menu in the footer. But Drupal 7 will not allow it. Drupal 7 ...
3
votes
5answers
5k views

Avoid access to profiles (user/%user/view)

I want to avoid access to user/%user/view, so only admins can see profiles. At first I tried with changing the permission user_view_access without any luck. I tried to use the hook hook_menu_alter: ...
14
votes
2answers
10k views

How can I get the nid of a node from the page alias?

I want to be able to get the nid but the only information I have is http://example.com/this-is-the-alias. Is there a drupal function to get either the internal path of /node/* for that alias if I am ...
12
votes
1answer
11k views

Can I add a custom link to “Main Menu” via hook_menu?

I'm trying to add a new link to the Main Menu from inside my module. Currently, this code: function custom_food_orders_menu() { $items['order_food'] = array( 'title' => 'Order Food', '...
9
votes
2answers
12k views

How do I display submenus separately from their menu tree? [closed]

I'm trying to display all 3rd level submenus for a menu item on one page, with each in its own display block. I've tried the Menu Block module but it only seems to work for the active trail, which ...
9
votes
3answers
14k views

How to completely wipe and rebuild drupal menus?

A while ago I found a cool blog post that detailed how to empty the menu tables, and rebuild the menu system with a drush php call, a necessity since the site will be unusable after emptying those ...
9
votes
1answer
5k views

Add tab / local task to a node

I've created a module called hotel_reviews. I've created the route node/{node}/reviews using hotel_reviews.routing.yml. hotel_reviews.content: path: '/node/{node}/reviews' defaults: ...
4
votes
2answers
2k views

How to get language specific path in twig?

In a twig template you are able to get a relative path by using {{ path('entity.node.edit_form', {'node': nid }) }}. The path will be in current language. Now I need to get the path in a specfic ...
4
votes
1answer
2k views

Assigning custom class to nested menu UL elements [duplicate]

I'm trying to theme my menu to alter the default UL classes. So far I'm working with the following function: function theme_menu_tree($variables){ return '<ul class="my-class">' . $variables['...
4
votes
1answer
2k views

Custom validation of route parameters

I have something like the following on my .routing.yml file: my.path: path: '/my-path/{node}' defaults: _form: 'Drupal\mymodule\Form\MyForm' requirements: _entity_access: 'node.update' ...
3
votes
5answers
3k views

How do I filter a menu to only show menu items translated into current language?

In my Drupal 8 project I have a menu containing menu items in english. Some of the items have a german translation. How do I filter the menu to only show the german items when viewing the site in ...
3
votes
3answers
5k views

Is there an accordion-style menu module?

I have been searching high and low for a module that integrates an accordion-style menu system in D7, similar to http://drupal.org/project/accordion_menu. Anybody know of one?
3
votes
1answer
664 views

How to add body class that carries the menu depth of the current page?

I am on Drupal 7. On the body tag, I need to create a new class that will detect the current page's menu depth. The class could carry the ID of the menu, then something that would detect the current ...
2
votes
2answers
1k views

Is there a way to use grouping settings for Bootstrap Tabs in Views?

Is there a way to use grouping settings for Bootstrap Tabs in Views?
2
votes
2answers
3k views

How to add a link in a menu with query parameters in paths

I want to add this link : resources?field_resources_type_tid_i18n[0]=130 in the main menu that point to a view with exposed filter. But When I save my link I just find resources without query ...
2
votes
1answer
480 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/...
2
votes
4answers
3k views

Language specific menu items when adding content

I am building a bilingual site that's English and French. When I add a content item in English, then go to Menu Settings, click on Provide a menu link, and click on Parent Item drop down menu, I get ...
2
votes
5answers
681 views

Split node edit tab in several tabs with panels (or programmatically)

I have a content type with many fields, so that loading node/%node/edit is a pain ! In order to split node edit form in smaller forms (menu tabs), I used Page Manager. What I did so far Enable the ...
0
votes
3answers
3k views

How do I render sub-menus?

I have a Drupal 7 installation that, for the purposes of this question, has just the core modules. Using the Structure->Menus->Main Menu form, I added some items to the menu and, using a ...
0
votes
1answer
2k views

Drupal 8 Menu Tree issue in my contrib theme possibly because of “Convert menu tree building to a service.”

Previously, in my Drupal 8 contrib theme, I was rendering the full menu tree as: function gratis_preprocess_page(&$vars, $hook) { // Build the main menu links tree. $vars['primary_nav'] = ...
0
votes
4answers
3k views

How to theme only top level menu?

I have the following menus about us company menu 2 our work menu 1 menu 2 news contact jobs I like to insert an extra li between each top level menus (about us, our work, news, ...
12
votes
2answers
562 views

Problem trying to create a views with tabs. Link of tab doesn't point to the path I set

I am trying to create a views with tabs: so that a page that has several tabs, the View has a primary page that shows all Article nodes, a tab for all Event nodes, and a tab for Blog nodes. Something ...
9
votes
2answers
3k views

How to add a local task tab to node view? [closed]

I'm trying to add an extra tab to the node 'view' and 'edit' tabs. My module is enabled fine and I have cleared cache, but my new tab doesn't appear. What am I missing? /** * Implements hook_menu()....
7
votes
3answers
12k views

How to show/hide a link based on a permission?

I'm looking for a way to hide/show a link from the main-menu if the current user has a specific permission. The menu item has already been created and the menu item links to a node that is controlled ...
6
votes
1answer
5k views

How to Trigger Existing, Non-Form Ajax from JavaScript Event

I'm trying to figure out AJAX in Drupal 8. I have a custom module that works, using AJAX to change the content of a div when a link is clicked. The API says: Many different events can trigger ...
5
votes
3answers
1k views

Add custom class to a particular menu

I need to know how to add extra class to a perticular menu.For example i have custom menu "menu-header-let",This menu is rendering like below, <ul class="menu"><li class="leaf first"><...