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
satheesh kumar (not verified)
Fri, 05/11/2012 - 07:22
Permalink
Thanks it working fine...
Thanks it working fine...
satheesh kumar (not verified)
Fri, 05/11/2012 - 07:37
Permalink
its also working... perfect
its also working... perfect way to use..
function hook_menu_alter(&$menu) {
unset($menu['linkname']);
}
tyler
Fri, 05/11/2012 - 09:50
Permalink
Thank you, your solution
Thank you, your solution looks much more elegant!
Elin (not verified)
Sat, 03/21/2015 - 05:59
Permalink
A much better way would be to
A much better way would be to set the menu type to MENU_CALLBACK instead of unsetting the menu item completely:
The advantage of that, the menu item and therefore the functionality of this menu item is still there, but there is no menu link for that path.
tyler
Sat, 03/21/2015 - 11:02
Permalink
My 2015 self definitely
My 2015 self definitely agrees with you on this! ;)