Posted By

Onfire60 on 09/24/10


Tagged

type content remove drupal tabs cms 6


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tronx


Drupal Remove Specific Tabs for a specific Content Type


 / Published in: PHP
 

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

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.

  1. /*
  2. *Removes Tabs From Specific Content types.
  3. */
  4.  
  5. <?php
  6. function phptemplate_preprocess_page(&$variables, $hook) {
  7. $nid = str_replace('page-node-','',$variables['template_files'][1]);
  8. $node = node_load($nid);
  9.  
  10. if($node->type == 'project') {
  11. theme_removetab(t('Edit'), $variables);
  12. theme_removetab(t('View'), $variables);
  13. theme_removetab(t('Outline'), $variables);
  14. }
  15. }
  16. function theme_removetab($label, &$vars) {
  17. $tabs = explode("\n", $vars['tabs']);
  18. $vars['tabs'] = '';
  19.  
  20. foreach($tabs as $tab) {
  21. if(strpos($tab, '>' . $label . '<') === FALSE) {
  22. $vars['tabs'] .= $tab . "\n";
  23. }
  24. }
  25. }
  26. ?>

Report this snippet  

You need to login to post a comment.