Remove Tabs from Drupal Site
Use the following function in '_phptemplate_variables' function in template.php. In the following code snippet, if I want to remove the "Edit" tab:
<?php
function _phptemplate_variables($hook, $vars = array()) {
if($hook == 'page') {
yourthemename_removetab('Edit', $vars);
// add additional lines here to remove other tabs
}
return $vars;
}
function yourthemename_removetab($label, &$vars) {
$tabs = explode("\n", $vars['tabs']);
$vars['tabs'] = '';
foreach($tabs as $tab) {
if(strpos($tab, '>' . $label . '<') === FALSE) {
$vars['tabs'] .= $tab . "\n";
}
}
}
?>- programmer's blog
- login or register to post comments
Above function would work for Drupal 5. Use following function in template.php for Drupal 6:
<?php
function yourthemename_preprocess_page(&$vars) {
// Remove undesired local task tabs.
// This first example removes the Users tab from the Search page.
yourthemename_removetab('Users', $vars);
}
?>
<?php
// Remove undesired local task tabs.
// Related to yourthemename_removetab() in yourthemename_preprocess_page().
function yourthemename_removetab($label, &$vars) {
$tabs = explode("\n", $vars['tabs']);
$vars['tabs'] = '';
foreach ($tabs as $tab) {
if (strpos($tab, '>' . $label . '<') === FALSE) {
$vars['tabs'] .= $tab . "\n";
}
}
}
?>