I have created custom module and have tried it to install on my website. Installation was correct expect problem with menu links. My hook_menu function was not called. I suggessted it is error in my module. Then I tried to install several public modules from drupal.org and their hook_menu were not called too. I flushed caches several times and it didn't help. Could anybody help, where can be problem? Is there any settings on website where I should look?

I am sure hook_menu was not called at all, because I added watchdog command into function body. It seems like problem with cache but I flushed caches several times and it didn't help

Comments

hook_menu() is only called on

hook_menu() is only called on install or when the menus are rebuilt (which should happen on clearing the cache).

Try rebuilding the menus.

If is still does not work, make sure you hook_menu() returns the menu items.

Still not working, you can post the function here.

thanks for the answer I tried

thanks for the answer

I tried to rebuild menus and then flush all caches but it didn't help. I have installed two public modules (Menu editor, Quiz) but I cannot use links of these modules. I tryied to look on all hook_menu_alter implementations on my web but I didn't see there something that should cause not calling hook_menus.

Menu editor module

<?php
/**
* Implementation of hook_menu().
*/
function menu_editor_menu() {
 
$items['admin/structure/menu/manage/%menu/poweredit'] = array(
   
'title' => 'Power Edit',
   
'page callback' => 'drupal_get_form',
   
'page arguments' => array('menu_editor_overview_form', 4),
   
// 'title callback' => 'menu_editor_overview_title',
    // 'title arguments' => array(3),
   
'access callback' => 'menu_editor_form_access',
   
'access arguments' => array(4),
   
'type' => MENU_LOCAL_TASK,
   
'file' => 'menu_editor.admin.inc',
  );

  return
$items;
}
?>

Quiz module

<?php
/**
* Implements hook_menu().
*/
function quiz_menu() {

 
// Take quiz.
 
$items['node/%node/take'] = array(
   
'title' => 'Take',
   
'page callback' => 'quiz_take',
   
'page arguments' => array(1),
   
'access callback' => 'quiz_take_access',
   
'access arguments' => array(1),
   
'type' => MENU_LOCAL_TASK,
  );

 
// Admin pages.
 
$items['admin/quiz'] = array(
   
'title' => '@quiz',
   
'title arguments' => array('@quiz' => QUIZ_NAME),
   
'description' => 'View results, score answers, run reports and edit configurations.',
   
'page callback' => 'system_admin_menu_block_page',
   
'access arguments' => array('administer quiz configuration', 'score any quiz', 'score own quiz', 'view any quiz results', 'view results for own quiz'),
   
'access callback' => 'quiz_access_multi_or',
   
'type' => MENU_NORMAL_ITEM,
   
'file' => 'system.admin.inc',
   
'file path' => drupal_get_path('module', 'system'),
  );

 
$items['admin/quiz/settings'] = array(
   
'title' => '@quiz settings',
   
'title arguments' => array('@quiz' => QUIZ_NAME),
   
'description' => 'Change settings for the all Quiz project modules.',
   
'page callback' => 'system_admin_menu_block_page',
   
'access arguments' => array('administer quiz configuration'),
   
'type' => MENU_NORMAL_ITEM,
   
'file' => 'system.admin.inc',
   
'file path' => drupal_get_path('module', 'system'),
  );

 
$items['admin/quiz/settings/config'] = array(
   
'title' => '@quiz configuration',
   
'title arguments' => array('@quiz' => QUIZ_NAME),
   
'description' => 'Configure the Quiz module.',
   
'page callback' => 'drupal_get_form',
   
'page arguments' => array('quiz_admin_settings'),
   
'access arguments' => array('administer quiz configuration'),
   
'type' => MENU_NORMAL_ITEM, // optional
   
'file' => 'quiz.admin.inc',
  );

 
$items['admin/quiz/settings/quiz_form'] = array(
   
'title' => '@quiz form configuration',
   
'title arguments' => array('@quiz' => QUIZ_NAME),
   
'description' => 'Configure default values for the quiz creation form.',
   
'page callback' => 'drupal_get_form',
   
'page arguments' => array('quiz_admin_node_form'),
   
'access arguments' => array('administer quiz configuration'),
   
'type' => MENU_NORMAL_ITEM, // optional
   
'file' => 'quiz.admin.inc',
  );

 
$items['admin/quiz/reports'] = array(
   
'title' => 'Quiz reports and scoring',
   
'title arguments' => array('@quiz' => QUIZ_NAME),
   
'description' => 'View reports and score answers.',
   
'page callback' => 'system_admin_menu_block_page',
   
'access arguments' => array('view any quiz results', 'view results for own quiz'),
   
'access callback' => 'quiz_access_multi_or',
   
'type' => MENU_NORMAL_ITEM,
   
'file' => 'system.admin.inc',
   
'file path' => drupal_get_path('module', 'system'),
  );

 
$items['admin/quiz/reports/results'] = array(
   
'title' => '@quiz results',
   
'title arguments' => array('@quiz' => QUIZ_NAME),
   
'description' => 'View results.',
   
'page callback' => 'quiz_admin_quizzes',
   
'access arguments' => array('view any quiz results', 'view results for own quiz'),
   
'access callback' => 'quiz_access_multi_or',
   
'type' => MENU_NORMAL_ITEM,
   
'file' => 'quiz.admin.inc',
  );

 
$items['node/%node/results'] = array(
   
'title' => 'Results',
   
'page callback' => 'drupal_get_form',
   
'page arguments' => array('quiz_results_manage_results_form', 1),
   
'access arguments' => array(1),
   
'access callback' => 'quiz_access_results',
   
'type' => MENU_LOCAL_TASK,
   
'file' => 'quiz.admin.inc',
   
'weight' => 3,
  );

 
$items['node/%node/myresults'] = array(
   
'title' => 'My results',
   
'page callback' => 'quiz_my_results',
   
'page arguments' => array(1),
   
'access callback' => 'quiz_access_my_results',
   
'access arguments' => array(1),
   
'type' => MENU_LOCAL_TASK,
   
'file' => 'quiz.pages.inc',
   
'weight' => 3,
  );

 
$items['node/%node/myresults/%quiz_rid'] = array(
   
'title' => 'User results',
   
'page callback' => 'quiz_user_results',
   
'page arguments' => array(3),
   
'access arguments' => array('view own quiz results'),
   
'type' => MENU_LOCAL_TASK,
   
'file' => 'quiz.pages.inc',
  );

 
$items['node/%node/results/%quiz_rid'] = array(
   
'title' => 'Results',
   
'page callback' => 'quiz_admin_results',
   
'page arguments' => array(1, 3),
   
'type' => MENU_LOCAL_TASK, // MENU_CALLBACK, MENU_SUGGESTED_ITEM, MENU_LOCAL_TASK, MENU_DEFAULT_LOCAL_TASK
   
'file' => 'quiz.admin.inc',
   
'access arguments' => array(1, 3),
   
'access callback' => 'quiz_access_results',
  );

 
// Add questions to quiz.
 
$items['node/%node/questions'] = array(
   
'title' => 'Manage questions',
   
'page callback' => 'quiz_questions',
   
'page arguments' => array(1),
   
'access callback' => 'quiz_type_confirm',
   
'access arguments' => array(1, 'update'),
   
'type' => MENU_LOCAL_TASK,
   
'file' => 'quiz.admin.inc',
   
'weight' => 2,
  );

 
// User pages.
 
$items['user/%/myresults'] = array(
   
'title' => 'My results',
   
'page callback' => 'quiz_get_user_results',
   
'page arguments' => array(1),
   
'access callback' => '_quiz_user_results_access',
   
'access arguments' => array(1),
   
'type' => MENU_LOCAL_TASK,
   
'file' => 'quiz.pages.inc',
  );

 
$items['user/quiz/%/userresults'] = array(
   
'title' => 'User results',
   
'page callback' => 'quiz_user_results',
   
'page arguments' => array(2),
   
'access arguments' => array('view own quiz results'),
   
'type' => MENU_CALLBACK,
   
'file' => 'quiz.pages.inc',
  );

 
$items['node/%node/questions/browser_ahah'] = array(//TODO: Add node access instead of user access...
   
'page callback' => 'quiz_browser_ahah',
   
'type' => MENU_CALLBACK,
   
'access arguments' => array('create quiz'),
   
'file' => 'quiz.admin.inc',
  );

 
$items['node/%node/questions/term_ahah'] = array(//TODO: Add node access instead of user access...
   
'page callback' => 'quiz_categorized_term_ahah',
   
'type' => MENU_CALLBACK,
   
'access arguments' => array('create quiz'),
   
'file' => 'quiz.admin.inc',
  );

 
$items['node/%node/results/browser_ahah'] = array(
   
'page callback' => 'quiz_results_mr_browser_ahah',
   
'type' => MENU_CALLBACK,
   
'access callback' => 'quiz_access_results',
   
'access arguments' => array(1),
   
'file' => 'quiz.admin.inc',
  );

  return
$items;
}
?>

Do they work if you uninstall

Do they work if you uninstall your custom module and rebuild the menus?

You say hook_menu() is not

You say hook_menu() is not being called - how are you diagnosing this? What are the symptoms?

Jaypan We build websites

I have added command to first

I have added command to first line of hook_menu body:

<?php
function mymodule_menu() {
watchdog('mymodule', 'test');
?>

I do not see any log in recents logs.
thanks
Tomas

Are any pages on your site

Are any pages on your site accessible? If they are, then hook_menu() is being called. If they aren't, then hook_menu() isn't being called.

The more accurate test would be to do the following:

<?php
function my_module_menu()
{
 
$menu['some_path'] = array
  (
   
'title' => 'some_path',
   
'page callback' => 'my_page_callback',
   
'access callback' => TRUE,
  );
  return
$menu;
}

function
my_page_callback()
{
  return
'Page found';
}
?>

Add the above code (changing my_module to your module name), clear your cache, and go to the path /some_path. If you see the page, hook_menu() is being called. If you don't see the page, then you have bigger problems :D

I suspect that either hook_menu is being called, and your watchdog call is not working for some reason, or else you have an error in your code, or your module is not enabled. Using the above code will give us a position to start from.

Jaypan We build websites

thanks I will try. But the

thanks I will try. But the fact is, I tried to install two public modules and their paths were not registered. So it is not a typo in my custom module.

So core paths are being

So core paths are being registered, but contributed module's paths are not? Is that correct?

Jaypan We build websites

How are you installing these

How are you installing these modules? Are they listed in the admin modules page? Do they appear as enabled in that list?

Hi If your site is working,

Hi

If your site is working, then probably your hook_menu() is working.

Also, check the menu_links table for seeing whether your paths are registered there

I also have this problem

I have several contrib and custom modules which have hook_menus working as expected. I am installing the WYSIWYG module, but the hook_menu in that module is not being called. I've tried DPMing out a message in the function, then cleared the cache. No message. The menu items in the WYSIWYG module are not registered in the menu_links table..

I initially installed via Drush, but have tried uninstalling and manually reinstalling.

I had solved it just reusing

I had solved it just reusing older version of my database. I had some wrong saved data in database and system blocked calling hook_menu. I don't remember what particular problem was, I just used last saved database with working version.

Hi, try instal another

Hi,
try instal another module, whether problem is not just in wysiwyg module

nobody click here