hook_menu_alter

MDF - July 29, 2009 - 07:36

I want to override the following part of code in "Contact" module which is located in hook_menu so that the type of item changes to MENU_NORMAL_ITEM instead of MENU_SUGGESTED_ITEM.

<?php

    $items
['contact'] = array(
   
'title' => 'Contact',
   
'page callback' => 'contact_site_page',
   
'access arguments' => array('access site-wide contact form'),
   
'type' => MENU_SUGGESTED_ITEM,
   
'file' => 'contact.pages.inc',
  );
?>

I wrote anther module named "Advanced contact" to override this using hook_menu_alter
<?php
function advanced_contact_menu_alter(&$callbacks){
}
?>

Now I don't know how to use $callbacks parameter to change the type to MENU_NORMAL_ITEM. What is your opinion?
Thanks in advance.

<?phpfunction

j_ten_man - July 29, 2009 - 11:50

<?php
function advanced_contact_menu_alter(&$callbacks){
 
$callbacks['contact']['type'] = MENU_NORMAL_ITEM;
}
?>

Be sure to flush the menu cache or else you will not see this change.

thanks, I tested your code

MDF - July 30, 2009 - 07:26

thanks,
I tested your code and cleared the cache, but it does not work, the "Contact" item in navigation menu is still hidden.
What is the problem ?

You can just enable the

prakashp - July 30, 2009 - 09:58

You can just enable the 'Contact' menu item by going to 'admin/build/menu-customize/navigation' i.e.
Administer > Menus > Navigation

From your post it seems that is what you want.

 
 

Drupal is a registered trademark of Dries Buytaert.