Question:

Hide menu item in specific block/region

Lincoln: 5 days ago

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.

Thanks,

Steve

Answer:
Waylon: 5 days ago

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