We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [routes]

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

Filter by
Sorted by
Tagged with
4
votes
2answers
973 views

Show menu link descriptions for a custom navigation menu

I have the following navigation, displayed in page.tpl.php: theme('links', array('links' => menu_navigation_links('menu-site-navigation'))); There are four navigation elements that show up. I ...
4
votes
1answer
2k views

“Add link” in my account menu

The user account page (http://example.com/user) consists of some default tabs like "View," "Edit," etc. I want to add my menu link over there. The content to be returned should depend on the user ...
4
votes
1answer
2k views

Theme output of submenu

I have a menu that should look like this: <ul class="subpagemenu"> <li><a href="xx">xx</a> <ul> <li><a href="xx">xx</a></li> </ul> &...
4
votes
3answers
4k views

How can I hide menu items based on permissions?

In my main menu I have a "menu item 1" that links to mynode1. I have successfully implemented hook_permission() and hook_node_access() so that users who do not have the "access menu item 1" ...
4
votes
6answers
3k views

Creating “Welcome <username>” special menu items

I want to create special menu items with title "Welcome ". I want to make it as special menu item (without link to any node), that shows sub-menu on hover. For that I have used Special Menu Items ...
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\...
4
votes
1answer
1k views

Views Menu Tabs and Ajax?

Is it possible to use menu tabs/default menu tabs available in Views, along with ajax, so that hitting a tab does not load a new page?
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-...
4
votes
1answer
153 views

Drupal 6: Having a menu where more than one Item is active

I'm trying to build a menu where a node can be a child of more than one item. That's not really an issue because Drupal 6 can handle it. However only one parent menu item will be active. It's some ...
4
votes
1answer
570 views

Providing menu route parameter values from url

Suppose I have the following route in my ej.routing.yml file: ej.form.user.profile: path: '/user/{user}/ej_profile' defaults: _title: 'EJ Profile' _form: '\Drupal\ej\Form\User\ProfileForm' ...
4
votes
3answers
674 views

Filter menu parent dropdown by language for multilingual site?

I am working on a multilingual site that has about 60+ pages per language. When an admin user wants to add a page to the navigation menu its becoming quite the task because literally every single link ...
4
votes
1answer
2k views

Difference between router path and link path?

I have recently started looking into the drupal menu system. I am not able to understand the difference between a router_path and the link_path. Both point to the same location in my installation.
4
votes
2answers
2k views

How to change MENU_LOCAL_TASK title for the View and Edit tabs according to content type? [duplicate]

I am trying to change the title ( tab text ) of the standard Drupal menu local task tabs 'View' and 'Edit'. I want them to reflect the content type of the current node. So on the page node/1234 ( ...
3
votes
3answers
956 views

Where is the Administer menu?

I can't find the "Administer" menu or it's members "Content Management" or "Site Building". I've tried disabling and re-enabling the core menu module, but still cannot see these menus. This is what I ...
3
votes
3answers
11k views

Create alphabetical pager

I want to list all the posts with alphabetical headings like this site: How can I do this with drupal 7 using views?
3
votes
2answers
3k views

How do I implement the equivalent of hook_url_inbound_alter()?

I'm working on a module which will resolve URLs to entities by altering inbound URLs so that if they contain an entity ID with following pattern "-{entity_id}" user will be redirected to correct URL. ...
3
votes
2answers
4k views

Alter menu structure when using Superfish menu

I am using Superfish menus. I wanted to add a <span> tag before each <a> tag for menu links. I tried the following code: function mytheme_menu_link($variables) { $element = $variables[...
3
votes
4answers
4k views

How to remove bullets from drupal menu?

I have created a drupal menu and added a couple of links. Unfortunately, when displayed, these come with bullets. How can I remove these? I am using the Precise theme, but it does not seem to be added ...
3
votes
2answers
3k views

How can I add a tab to the admin/content page

I'm new to drupal, so sorry if this is a stupid question. While developing a module, is it possible to add a tab to the /admin/content page (where by default there is content, comments, files) ...
3
votes
5answers
3k views

HTML In a hook_menu title callback

I'm trying to insert a span class around some text in title callback. It passes through a t() function so all the html is escaped. Is there a way round this? My code is: function ...
3
votes
1answer
2k views

Override specific routing from a core module

I want to stop anonymous users being able to access a specific set of routes offered by the core/forum module. specifically: forum.index: path: '/forum' defaults: _controller: '\Drupal\forum\...
3
votes
1answer
3k views

How can I render an URL path from a custom route?

In my module.routing.yml (and using D8), I have a module_new route associated with the /module/name path. I want to render this path in my module. How can I show http://example.org/module/name on a ...
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 ...
3
votes
2answers
2k views

How can I create menu links to external URLs?

With my module MYMODULE I would like to create external link and place it into main menu. Is it possible to do that in MYMODULE.links.menu.yml file or MYMODULE.routing.yml? Something like this??? ...
3
votes
3answers
4k views

Finding menu item ID

How to find a menu item pointing to the specific node? On node creation I want to create a main_menu link for the node. With menu_rules it is relatively easy. The problem arises when the parent ...
3
votes
2answers
6k views

Using “access callback” and “access arguments” provided with hook_permission

how can I check user's access first based on some permission and if user passed this check then execute access callback function with some parameters in path, some thing like this: $items['order/add/%...
3
votes
4answers
8k views

user/%/edit - remove it from tab and make it an actual menu item

I am pretty clueless on how drupal handles such things and I can't seem to grasp the context. I want a menu link to user/%/edit (using menu token already). But as it seems /edit is a 'tab' item of ...
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
4k views

What is the difference between page callback and access callback?

Can anyone please explain with example for difference between page callback and access callback in drupal?
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: ...
3
votes
2answers
1k views

Change '/user(/*)' URLs to 'profile(/*)'

I want change all /user, /user/* urls by /profile, /profile/* urls. From a custom module, I copied all user routes (found in /core/module/user/user.routing.yml) to my custom .routing.yml file. I ...
3
votes
1answer
2k views

How to alter the path of login page?

I want to alter the path of login page, /user/login, to /ulogin. How can I accomplish this?
3
votes
3answers
1k views

How do I get the router name from the internal path?

If I know the internal path of my page (e.g. 'node/1') how do I get the router name? I need it it to generate an internal url: $url = Url::fromRoute($router_name); I found Url::getRouteName, but I'...
3
votes
2answers
2k views

Why is my sub-menu not loading in main menu?

<div class="row" id="mainNav"> <?php print theme('links__system_main_menu', array( 'links' => $main_menu, 'attributes' => array( 'class' => 'menu', ), )); ?> &...
3
votes
4answers
3k views

How to hook theme of the main system menu in drupal 7 to display only some of the elements?

I want to modify the main system menu in Drupal 7. Actually I want to display only some specific elements of the menu and hide some other specific elements, in a given case (which I will implement by ...
3
votes
2answers
1k views

how to restrict access in routing.yml based on roles

I know how I to restrict access in the routing.yml file based on permissions, but how can I do it based on roles? This is how to do it by permissions: requirements: _permission: 'access ...
3
votes
1answer
1k views

Redirect using a path [duplicate]

My question seems to be obvious but I really don't find the solution. Well, I want to redirect to my view just after connexion. I try to use $form_state->setRedirect,but It's seems it needs the route ...
3
votes
1answer
904 views

Getting the URL for every language

I have a route of a page, and I want get the link for it on every language of my site. On my site the contact page is: en/contact for English, and es/contactenos for Spanish. I am trying using the ...
3
votes
1answer
4k views

altering access callback in hook_menu_alter [closed]

So, I want to set a new function as access callbacks for URLs specified by registration module. Specifically I want only users that have the update rights on the node to be able to manage ...
3
votes
5answers
5k views

Second level in the menu

I have created a menu with items and one item has second level. So I created child links. The problem is that the item which has second level links to some page and I would like to make it to link ...
3
votes
2answers
2k views

How to make a MENU_LOCAL_TASK on a user's profile only appear on their profile?

I use logic like this to place a tab on each user's profile page so users can view analytics from the usage of a WebApp: // maps a url to a sub-page of user's profile, url to user's Analytics-...
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
6k views

How to change HTML output of main menu

When I output the main menu this is the html that gets generated: <ul id="main-menu" class="links inline clearfix"> <li class="menu-218 first active"><a href="/drupal/" class="...
3
votes
2answers
1k views

How to create custom placeholders on hook_menu, like “%node”?

For example, for menus like /node/%node: when /node/1 is accessed, drupal automatically translates 1 as node_load(1); I wanted to create something like /path/%student where, when /path/1 is accessed, ...
3
votes
2answers
3k views

Use hook_menu_alter to change access callbacks

I'm trying to working with hook_menu_alter, I'm tryng to change, for example, access callback to an admin path (admin/config/account/people/fields). I've create a permission and I've added to a role. ...
3
votes
3answers
2k views

Menu doesnt appear on custom 'not found' page

On my site I have configured things so that the home page will appear if the URL doesnt exist. (ie in admin/settings/error-reporting I set a replacement page for the 404 page.) The problem is that ...
3
votes
1answer
2k views

Setting a View's Menu Item to a Sub-Menu

I'm using Drupal 7.10 and Views 3.1. This seems like it should be simple but I can't find an answer. I have a menu structure similar to the following: Main > About Us > History ...
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
177 views

Why does this route work with a slash and not a dash?

I have defined a custom dynamic route that works, but isn't ideal: /** * Defines dynamic routes. */ class GuideUnitRoutes { /** * {@inheritdoc} */ public function routes() { $...
3
votes
1answer
99 views

Routes node.add.CONTENT_TYPE are no longer available starting from Drupal 8.4 in hook_menu_links_discovered_alter()?

If you implement the hook_menu_links_discovered_alter() hook in Drupal 8.3 you have access to change the links with a code like this: /** * Implements hook_menu_links_discovered_alter(). */ ...