Hide Local Task Menu Tabs in Drupal

Category:

Here is how you can hide certain local task menu tabs in Drupal by utilizing theme_menu_local_task. The example below demonstrates how to hide the 'View' tab on user account profile pages. This code goes in your theme's template.php file.

function tf_menu_local_task ($link, $active = FALSE) {
  if (strpos($link,"/users/") !== false) { // we are on a user's page...
    if (strpos($link,">View<") !== false) { /* hide the 'view' tab */ return ''; }
  }
  // default render
  return '<li ' . ($active ? 'class="active" ' : '') . '>' . $link . "</li>\n";
}

So, with this code we are actually preventing it from being rendered.

Comments

Thanks it working fine...

its also working... perfect way to use..

function hook_menu_alter(&$menu) {
unset($menu['linkname']);
}

Thank you, your solution looks much more elegant!

Add new comment