Remove Tabs from Drupal Site

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.


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";
    }
  }
}
?>

                                     
4 points

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";
    }
  }
}
?>

Anonymous's picture
Created by Anonymous

Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.