Questions tagged [hook-menu]

This hook enables Drupal modules to register paths in order to define how URL requests are handled.

As defined in Drupal API Docs:

This hook enables modules to register paths in order to define how URL requests are handled. Paths may be registered for URL handling only, or they can register a link to be placed in a menu (usually the Navigation menu). A path and its associated information is commonly called a "menu router item". This hook is rarely called (for example, when modules are enabled), and its results are cached in the database.

60 questions
5
votes
1 answer

Drupal 7: Add Item to Admin Toolbar/Menu Programmatically

I'm building a fairly involved module for my company with a number of different configuration pages. I'd like there to be a menu item in the admin bar across the top that has all the sub menu items as well. I know how to add a single item to that…
LoneWolfPR
  • 3,978
  • 12
  • 48
  • 84
3
votes
1 answer

How to avoid Drupal 7 user ID in user path?

I have the following in my theme: $items['user/%user/sms-services'] = array( 'title' => t('SMS Services'), 'page callback' => 'sms_user_page', 'page arguments' => array(1), 'access callback' => 'user_is_logged_in', 'type' =>…
rockstardev
  • 13,479
  • 39
  • 164
  • 296
3
votes
1 answer

Drupal: $_POST and MENU_CALLBACK. How works?

i've read this ad 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 content'), 'access callback' => true, 'type'…
linuxer
  • 161
  • 1
  • 9
2
votes
1 answer

How to add a menu item from my custom Drupal 7-module

with my custom drupal-module i'm trying to insert add a menu-item to a menu using hook_menu(). It should display the user-name linked to the user-profile. (My task could be similar to Add menu item/link to Drupal menu (programatically?).) [Edit:] I…
Piezo Pea
  • 125
  • 1
  • 3
  • 11
2
votes
5 answers

Drupal 6: How can i add a link to a hook_menu()?

I have my own module and I implemented a hook_menu, I want that one menu-item redirect (The menu has to stay active) to an existing webform page, this page is: ?q=node/add/webform. $items['adminQuestion/create'] = array( 'title' => t('Crear…
McSas
  • 2,224
  • 3
  • 27
  • 42
2
votes
1 answer

How can I alter the body_classes_array through hook_menu?

I'd like to add a css class to the body_classes_array as if I were using template_preprocess_page to alter &$vars, but I'd like to do it through hook_menu() page callback. Is it even possible to do?
user426849
  • 21
  • 1
2
votes
1 answer

Drupal: menu items tokens?

I need to add a menu item with the following link: user/16/addresses It is the link to a tab of user profiles. Of course 16 is the user ID and it should change according to the user. Can I use tokens directly into menu items ? such as [uid] ? thanks
aneuryzm
  • 63,052
  • 100
  • 273
  • 488
2
votes
1 answer

Drupal 7 Custom Template Using hook_menu

I am trying to make custom page template using these hooks in Drupal 7 but it shows blank page when i open in browser. Here is my code /* Implements hook_menu(); */ function story_menu () { $items['story/filters'] = array( 'title' =>…
Touqeer Shafi
  • 5,084
  • 3
  • 28
  • 45
2
votes
1 answer

How to register a wildcard url in Drupal with the hook_menu?

I'm starting to work with Drupal and I'm really confused as how to create a hook_menu function that allows you to register a URL with 1 or 2 different values, that can be hidden and not displayed in the breadcrumbs. Any help on this would be much…
jamadri
  • 926
  • 3
  • 17
  • 32
2
votes
1 answer

Print a 'node/add' form in a lightbox with Drupal

I'm having some troubles printing a 'node/add' form in a lightbox. I have in my custom.module a hook_menu like this: $items['get-form/%'] = array( 'title' => t('Get a form'), 'description' => t('Get form'), 'page callback' =>…
Ignacio Sánchez
  • 409
  • 4
  • 14
2
votes
1 answer

How to display custom html block in Drupal using theme?

Having some module, defined some url in hook_menu() and need to display there some theme (modules/mymodule/templates/mytheme.tpl.php). How do I show mytheme.tpl.php content on needed url? function mymodule_menu(){ $item = array(); …
Jokerius
  • 1,310
  • 1
  • 14
  • 22
1
vote
1 answer

Drupal 7: how to hide link to secondary tab?

I'm writing a Drupal 7 module. Therefore, parts of my implementation of hook_menu() look like this: $items['admin/mymodule/a'] = array( 'title' => 'A', 'page callback' => 'mymodule_a', 'access arguments' => array('administer mymodule'), …
1
vote
1 answer

Drupal 7 .10 hook_menu implementation error

I am trying to figure out why hook_menu implementation is not working anymore after upgrade from 7.4 to 7.10 for a custom module Menu links were working properly until update to latest version. after update all custom module links are deleted from…
arnaudom
  • 11
  • 1
1
vote
1 answer

Drupal dynamic internal redirect

What I want is pretty simple. I have registered a path function spotlight_menu() { $items = array(); $items['congres'] = array( 'title' => 'Congres', 'title arguments' => array(2), 'page callback' =>…
Nealv
  • 6,856
  • 8
  • 58
  • 89
1
vote
1 answer

Do not show path to sub menu items in breadcrumb

I would like to hide the path to sub menu item which is shown in the breadcrumb once you request a page by clicking the sub menu. Here is the code I am using to create a menu item and three sub menu items: $items['what-to-expect'] = array( …
iamyourfriend
  • 105
  • 1
  • 10
1
2 3 4