Questions tagged [routes]

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

Filter by
Sorted by
Tagged with
5
votes
4answers
2k views

Add a local task tab for a content type only

Someone can help me ? I want to display a tab only when the content type is 'test'. Here's my files. mymodule.routing.yml : mymodule.check_test: path: '/checktest/{node}' defaults: ...
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"><...
4
votes
2answers
2k views

Displayng menu description under main-menu links in Drupal 7

I am trying to display the menu description under menu links for the main-menu in my custom theme. I have tried overriding the function as given in this post http://fusiondrupalthemes.com/forum/using-...
3
votes
2answers
12k views

How to replace the Bartik default menu with Superfish

Since the default Bartik menu doesn't allow me to create a sub menu with styles, I created a Superfish menu. How can I replace the Bartik default menu with Superfish on the exact place?
3
votes
2answers
6k views

Load custom template from MENU_CALLBACK

Here's my current situation: I have an external authentication platform that loads in Drupal via an iframe. When the user is authenticated, the external application redirects the user to a Drupal ...
3
votes
1answer
5k views

How to build a dynamic menu structure

I'm building a module for which I want to create two dynamic menus: one main menu with each menu item being a group name that the user belongs to (the groups come from a different database) and a ...
3
votes
3answers
14k views

How to make the main menu expanded?

I have set main menu items expanded but when I print them in page.tpl.php($main_menu) there are no children for menu items.How can I make them expanded?
3
votes
2answers
3k views

Drupal 7 main-menu - change item text if user logged in

I'm using Drupal 7's 'main-menu' to run my site's navigation. In my design, the links to join and sign in are in the main nav. My join link goes to /user/register so it vanishes when a user is logged ...
3
votes
3answers
5k views

How do I add a menu item to the main navigation from a custom module in Drupal 8?

For my custom Drupal 8 module I want to add a link to the default main navigation menu of the site. What parent ID do I have to give to insert my menu item into the main menu? I currently have the ...
2
votes
1answer
2k views

How can I customize a menu to be intuitive for my users: show user name, have dropdown items

I am looking to create a user menu. The menu when not logged in should have two options: 1. create account 2. sign in. These items will be displayed in-line. Once logged in, I want the menu to have ...
2
votes
2answers
798 views

Find Menu Link Title given URL alias, to replace node Title in breadcrumbs

In Drupal 8, how can one determine the Menu Link Title of a node, given its URL and other information like its route & parameters? This is to modify the core path-based breadcrumbs (...
2
votes
1answer
2k views

Access denied for admin?

Why when I am logged as admin I get an access denied page, the page is custom like mysite.com/test - added by the custom module: function onthisdate_menu() { $items = array(); $items['test2'] = ...
2
votes
2answers
4k views

How to create navigation menu on sidebar with different navigation links displayed on different pages?

I am using Drupal-7. I have created Dropdown menu with Megamenu. Now, I wanted to create navigation menu on left side that menu items will be different on each page. I have created navigation block ...
1
vote
1answer
739 views

Form submit results in “Too many redirects” error for anonymous users

I have a custom route on my site at /search. This page has a couple of forms on it (defined with FormBase). When I am logged in, the form appears to work. When I am anonymous, many many requests ...
1
vote
3answers
5k views

How do I change html structure of menu (primary links for example) to my own?

The default HTML structure of the primary links menu is not what I'd like it to be. How can I override it with my own version?
1
vote
1answer
980 views

Content type slug in route, how?

I have a content type "Company", each company will have a login page that show the logo of the company and a login form via Restful. I have created a module that define a route: company_md.login: ...
1
vote
3answers
3k views

My hook_menu_alter() and page callback don't get triggered

This question relates to How do I redirect a taxonomy menu item to another path? I followed the recommendations of Clive and wrote a hook_menu_alter to provide my callback. function ...
1
vote
1answer
4k views

Using images instead of text in menus [closed]

I have a client who wants to use images instead of text for his menu items. Is there a native way to do this in Drupal 7?
1
vote
1answer
3k views

Using hook_menu() with hook_permission() - Access denied [closed]

Can someone see anything wrong with this hook_menu() and hook_permission() code? I am able to see the permissions in the admin menu, admin/people/permissions. I allow access to los user front for ...
1
vote
2answers
244 views

Identifying the level of menu items in the item array?

I have a D7 menu of nearly 300 terms in a 3-level hierarchy. Rather than generate them one at a time in the UI, I would like to generate them using code. I am using the book 'Pro Drupal Development' ...
1
vote
2answers
904 views

Altering menu local task title

I'm trying to override the title of a system provided local task. I have the following code which works for uid 1 but not authenticated users: function test_controller_menu_local_tasks_alter(&$...
1
vote
2answers
1k views

Messed Up Drupal Site, truncated all cache, menu_router, registry_file and now I can't access site

After disabling comment module, I could not access some modules, so I researched how to get that fixed and end up following this. I cleared all the cache_table, menu_router and registry_file. This ...
1
vote
1answer
778 views

Altering Create New account tab link in user login page

I tried using form alter for menu of tabs in /user page, that shows "create new account", "login", request password is it possible for us to alter the link so that the create new account can go to "...
0
votes
0answers
129 views

Active menu trail with 2 menu items linking to same content

On a D6 site, I have a content accessible by 2 ways in my primary links: Section A : "my content" Section B: "my content" My problem is that the active trail is set on Section A, but I would like ...
0
votes
3answers
6k views

Superfish Menu override CSS

I am using superfish menu module with drupal 7.7 and I can't figure out how to override the CSS in space.css or any other superfish stylesheet. If anyone knows how to, please share your input.
6
votes
3answers
5k views

Dropdown Menu Dummy Link

One of my menu items I have, I want to make it so that only the child links are clickable, and the parent is not. Is there a way to make the parent a sort of "Dummy Link" just to set a hierarchy for a ...
5
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\...
5
votes
1answer
4k 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?
5
votes
3answers
5k views

Dynamic menu items

The Drupal 8 menu system is much more logical than in previous versions, and breaking the many functions of hook_menu() into multiple YAML files makes perfect sense and simplifies the creation and ...
5
votes
5answers
3k views

Show a link in a menu even if user has no access

I created a node/add/content-type menu link in my main menu, but it only shows to those who have access to it. How could I show this to everyone, including anonymous users, and use http://drupal.org/...
5
votes
1answer
2k views

How to apply theme_menu_tree to only the top <ul> menu

I am using the following function in the template.php (drupal 7) to override the original menu output. However, the tags in all levels are also affected. I wonder how to only apply it to the top/...
4
votes
1answer
4k views

Menu secondary tabs

How do I create secondary local tasks with hook_menu in Drupal 7? For instance, if I wanted to add a new tab to a node, that presented multiple tasks beneath it? View Edit Update Price Photo Person
4
votes
2answers
2k views

Db_Query Fatal error: Unsupported operand types

I am simply trying to return the rows from a table in my db but i keep getting this error thrown back at me no matter what I do "Fatal error: Unsupported operand types in C:\xampp\htdocs\d7\includes\...
3
votes
1answer
3k views

How to add custom fields to menu items

I've been looking at using menu attributes module for Drupal 7 to add an extra field to the menu navigation system. However this adds a new attribute to the attribute array and thus prints it out in ...
3
votes
0answers
152 views

How do I ensure active menu items are highlighted for Views with Better Exposed Filter arguments

I'm using Better Exposed Filters on a clothing site. There are various types of products listed using Better Exposed Filters (to choose between Mens/Womens/Kids). The Mens and Womens pages are ...
3
votes
1answer
613 views

Matching a route with a “file path”

I'm trying to debug a route that should work like the one(s) used by the private: file scheme (i.e., a path like system/files/path/to/file, where path/to/file is an arbitrary string that may contain '/...
3
votes
1answer
1k views

Display bare HTML from hook_menu()

What would be the cleanest way to route URLs to functions and return only the HTML output from those functions (a.k.a. the menu callback)? If I use hook_menu() the string that's returned will be the ...
3
votes
1answer
913 views

How to render custom view mode in d7

I'm trying to render nodes with a custom view mode, having another tab for each node in the same place than "Edit", "View", etc. So I have declared my custom view mode with hook_entity_info_alter, my ...
3
votes
1answer
329 views

l() is not being called correctly in menu.inc

I had been getting this error message: PHP Fatal error: Unsupported operand types in /var/www/www.ruv.is/pressflow/includes/common.inc on line 1588 So I did a backtrace and this is what it ...
3
votes
1answer
2k views

Why are there so many different ways to translate menus?

I'm very confused about the way Drupal 7 translates menu items. I have many modules installed, so I'm not sure which would be relevant to state; in fact, I don't have my head fully wrapped around ...
2
votes
3answers
613 views

Menu Callback and CSRF

How can I get a link with the correct csrf token for an internal path? Here is what I have: in mymodule.routing.yml mymodule.test: path: '/mymodule-test' defaults: _content: 'Drupal\mymodule\...
2
votes
1answer
901 views

Only show menu level 2 from active trail (with option Show as expanded)

I'm trying to do something pretty basic in my perspective, but I keep failing at this simple task. My website has a main menu that is displayed on top of the page that is 2 levels deep (hence the ...
2
votes
1answer
687 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 ...
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
0answers
135 views

How to reorder Book module menu through Database?

How to re-order Book menu faster, optionally through Database? I have a big problem to reorder menu/ navigation for Book module.... It is supposed by drag-and-drop - I have 318 items in list , some ...
2
votes
1answer
365 views

Menu system - accepts extra args on path

Awhile back, working in Drupal 6, I found an issue in which a valid path, say: example.com/real/page would be served if the following did not exist: example.com/real/page/fake-arg I thought it ...
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
1k views

Generating arbitrary internal URLs

I'm generating the URL inside a controller in a custom module. The URL I generate is to pages on the same site, but not in the module. I want to append an arbitrary number of slugs to the end of the ...
2
votes
1answer
125 views

How do I create a configuration menu with the selected section name?

I want to create a menu in the admin section that is in the sitename/admin/config path. As of now, I am doing this. Routing file custom_menu.adminmenu_section: path: '/admin/config/custommenu' ...
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/%...