Drupal 7 .10 hook_menu implementation error

571 Views Asked by At

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 table menu_links and menu_router.

After many attempts, I also installed a fresh version for D7.10 and created a simple custom module with one item link only (see code below) for testing purpose only. The link is not implemented once the module is enabled. Tables menu_links and menu_routers are not updated. I have been looking around many possible errors and solution without success. Really stacked now. What makes me doubt is that I do not see anybody else having the same issue... Any suggestion? Thank you

function misite_menu() {
$items = array(); 
$items['a/main'] = array(
'title' => 'main',
 'page callback' => 'main',
 'description' => t('Main front page'),
 'access callback' => TRUE,
 );
return $items;  
}

function misite_theme() {
return array(
'main' => array
(
  'template' => 'main',
  'variables' => array('title' => NULL),
),

);  
}

function main() {

$path = drupal_get_path('module', 'a'); 
$title = t('');
$build['mainelement'] = array(
'#theme' => 'main',
'#title' => $title,
);
$output = drupal_render($build);
return $output;
}
1

There are 1 best solutions below

1
On

From the looks of this line:

$path = drupal_get_path('module', 'a'); 

Your module is called a.

In Drupal, the convention for hook naming is MODULE_NAME_name_of_hook() (see http://api.drupal.org/api/drupal/includes--module.inc/group/hooks/7).

This is true for both hook_menu() and hook_theme() so in your case if the module is called a your functions should be names a_menu() and a_theme().

If you make changes to any hooks make sure you clear Drupal's cache so the relevant registrys are updated.