Stephen Wilson
Stephen Wilson

Reputation: 111

Drupal 7 – Hide menu item in specific block/region

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

Upvotes: 0

Views: 488

Answers (2)

Stephen Wilson
Stephen Wilson

Reputation: 111

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

Upvotes: 0

Prashant Kanse
Prashant Kanse

Reputation: 782

Not sure about template.php but you can go for hook_block_view_alter and change content as per requirement.

Cheers!!!

Upvotes: 1

Related Questions