Return to Snippet

Revision: 32427
at September 24, 2010 11:25 by Onfire60


Initial Code
/*
 *Removes Tabs From Specific Content types.
*/

<?php
function phptemplate_preprocess_page(&$variables, $hook) {
    $nid = str_replace('page-node-','',$variables['template_files'][1]);
    $node = node_load($nid);

    if($node->type == 'project') {
      theme_removetab(t('Edit'), $variables);
      theme_removetab(t('View'), $variables);
      theme_removetab(t('Outline'), $variables);
    }
}
function theme_removetab($label, &$vars) {
  $tabs = explode("\n", $vars['tabs']);
  $vars['tabs'] = '';

  foreach($tabs as $tab) {
    if(strpos($tab, '>' . $label . '<') === FALSE) {
      $vars['tabs'] .= $tab . "\n";
    }
  }
}
?>

Initial URL
http://groups.drupal.org/node/67463

Initial Description
Was trying to figure out a way to remove tabs for a content type where it was unnecessary. Place this in your theme template.php file and configure to your needs.

Example Usage: Organic Group View is created and page uses a menu tab. Unfortunately the tab gets added to all other content types. This is used to remove that tab for the other content types that aren't part of your group.

Initial Title
Drupal Remove  Specific Tabs for a specific Content Type

Initial Tags
drupal

Initial Language
PHP