I have two instances of main_menu on a page. One is in the header, using superfish. The other is in the sidebar, using menu_block.

I want to hide a menu item in the sidebar and show it in the header. Is this possible?

Could you use template.php to target a block/region?

For example:

function my_theme_preprocess_block(&$variables) {
  if ($variables['region'] == 'content' && $variables['block']->module == 'menu_block') {
    // What would go in here?  

Any help would be greatly appreciated.



  • 1
    What I understand is that you need to move a menu item from the sidebar menu to the header menu. Is that right?
    – gerzenstl
    Sep 26, 2014 at 13:16
  • No, I have two instances of the main_menu on a page and I want to hide a link in one menu but not the other. Sep 26, 2014 at 13:33

2 Answers 2


If I were you, I'd rather do this in my module code to access the links data:

function mymodule_block_view_alter(&$data, $block) {
  if($block->title == 'myblocktitle') {
    $data['content']['#content'][idofthenodelink]['#access'] = false;

And your link will no longer be accessible.

Here is the dpm($data['content']['#content']) after the operation:

enter image description here

  • Worked great. Can you use something instead of block->title ? Maybe the block Administrative title in case title is set to <none>? Sep 26, 2014 at 15:02
  • I'm no longer with my working computer and I cannot take a look at all accessible variables till tomorrow. If you have Devel module installed, you can call dpm($block) in this hook to see what you can use other than title. Hope it will help.
    – Djouuuuh
    Sep 26, 2014 at 15:18

It depends on your theme. I have seen some that hardcode the main menu into the template (bad style, but if so, you'll have to find the template and delete the section). More likely, you will see Main Menu in your "admin/appearance/settings" as an option that you can turn off for Global Display.

Then, if you want to add it in any other block, you can do so manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.