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
1
vote
2 answers

Passing values to functions through URI (instead of the GET method)

I'm writing a Drupal 6 module that sends a user ID + a randomly generated string to a function through the URI. I'm using the menu hook: function invites_menu() { // ... $items['invites/auth'] = array( 'title' => 'Are you human?', …
Aaron
  • 458
  • 4
  • 16
1
vote
3 answers

Multiple URLs pointing to same tab in hook_menu

Here's a basic menu structure I'm working with: function events_menu() { $items = array(); $items['events'] = array( 'title' => 'Current Events', 'access callback' => true, 'page callback' => 'page_event', …
ack
  • 14,285
  • 22
  • 55
  • 73
1
vote
1 answer

Drupal 8 hook_menu() to render hook_theme()

I am finally diving in to Drupal 8 for a project. In my module though I can not seem to nail down how to render a template from my module based on the route. In Drupal 7 I would normally do this custom.module function union_views_menu() { $items…
NicholasByDesign
  • 781
  • 1
  • 11
  • 33
1
vote
2 answers

Drupal module menu item not showing in menu primary-links

I'am trying to get a menu item to show in the 'primary-links'. i've read this, but that is not working. What am I doing wrong? /** * Implementation of hook_menu(). */ function modulename_menu() { $items = array(); $items['test'] = array( …
FLY
  • 2,379
  • 5
  • 29
  • 40
1
vote
0 answers

Drupal Custom Module Hook_menu not working with querystring params

I am sending a link out via email to users when they register that they must click and it will automatically direct and log them into the site. I'm getting a 404 error when trying to access this link. Example email sent…
Exziled
  • 473
  • 5
  • 20
1
vote
0 answers

Parent Accessible if any Children are

Is there a way to make a parent menu item accessible only if at least one of it's children are accessible? The below code demonstrates what I'm trying to do: function foo_menu() { $items = array(); $items['admin/help'] = array( …
Smern
  • 18,746
  • 21
  • 72
  • 90
1
vote
2 answers

How to append to a Drupal module page callback

Say you have a page callback from Module #1 using hook_menu(). You want to create Module #2 that would basically just append something on the bottom of Module #1's page callback (think of having some notes you wanted to add to the bottom of the…
stotastic
  • 796
  • 1
  • 5
  • 18
1
vote
1 answer

Locale module and language prefix in url

I had been working on module and well aware of hook_menu for passing url arguments to call back. For instance: $items['webtv/block/%/playlist/edit/%'] = array( ... 'page callback' => 'drupal_get_form', 'page arguments' =>…
Shoaib Nawaz
  • 2,302
  • 4
  • 29
  • 38
1
vote
1 answer

Drupal excessive menu parts

In a module development (webtv) I am providing a generic block that can be configured for its contents (playlists). On the configure form there is a list of added contents (playlists) along with links "add new playlist" and "edit" existing one…
Shoaib Nawaz
  • 2,302
  • 4
  • 29
  • 38
1
vote
2 answers

Wildcard Page Argument in hook_menu() not working

I'm trying to create a pagination type menu item that would allow the user to see older/newer content. The wildcard would represent the multiplier that would set the range from which the content is culled. This is the array created within my…
1
vote
2 answers

hook_menu not working on a custom module

May be I am something obvious but a simple custom Hello world module isn't working. I have spent a couple of days trying to fix this but no progress at all. hello_world.info name = Hello World description = "This module is to test hello world" core…
1
vote
3 answers

Drupal 7 menu error

I writing custom module for Drupal 7 and got the following warning: Warning: Invalid argument supplied for foreach() в функции menu_unserialize() (строка 400 в файле /var/www/auth/includes/menu.inc). My hook_menu is here: function…
1
vote
1 answer

Hook_menu selective menu tab display

I am using the following code to include a custom tab for my node types: function mymodule_menu(){ $items['node/%node/register'] = array( 'page arguments' => array(1), 'access arguments' => array('access content'), …
sisko
  • 9,604
  • 20
  • 67
  • 139
1
vote
1 answer

Drupal local_menu_task title

I have a page with multiple tabs rendered via hook_menu and MENU_LOCAL_TASK. Whenever I click a tab the title of the page in the content area changes to 'Home'. How can I set this to stay at 'My Settings'? Here's my code: $items['settings'] =…
Ken J
  • 4,312
  • 12
  • 50
  • 86
1
vote
1 answer

Drupal 6- 404 is not showing for menu item URL pattern implemented using hook_menu

I have a hook menu $items['mypage'] = array( 'title' => t('My Page title'), 'description' => '', 'type' => MENU_CALLBACK, 'page callback'=> 'my_home_page', 'access arguments' => array('access content'), ); Now when I access a…
subi
  • 89
  • 7