Friday, July 1, 2011

How to remove the unwanted tabs in drupal


The simple way to do this is need to customize the tabs in template.php file of the respective theme for ex>garland.

<?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);
 yourthemename_removetab('By task', $vars);
}
?>

First to write above code for calling the removetab function.

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

In this function you can remove the mentioned tab.

This code works for me.Hope this may little bit helps to you.

No comments:

Post a Comment