Search code examples
phpdrupaldrupal-7

How to hide main menu in drupal


I have do some search at this point, none of these working.

I have used the following code:

function <module_name>_menu_alter(&$item)
{
    $item['node/%node']['access arguments'] = array(0);
    $item['node/%node']['access callback'] = 'callback';
}

function callback()
{
    ...
    return false
}

but i find it only controls the access, the link is still there.

and I try another way as :

function <module_name>_menu_link_alter(&$item)
{
    $item['hidden'] = 1;
}

Yeah this works on most menu EXCEPT the main menu, this really drives me crazy.

BTW the main menu is just articles, I click the 'Provide a menu link' checkbox to add it to the menu.

Any ideas about how to hide them in hook function?


Solution

  • If you want to hide the main menu mabe you should go to your theme settings and uncheck " Main menu" checkbox.

    If you wann to hide just an item, go to content and uncheck 'Provide a menu link'.