I'm trying to control some output based on a node's taxonomy terms. In template.php, I've got a function that creates tabs based on the node's content type. "Resource Programs" and "Resource Forums" have an Instructions tab; some other content types ("Exhibits" and "Exhibitions") have an Objectives tab instead. Then all content types have another 3 tabs that are the same for all.
Now I've got to figure out a way to hide that Instructions/Objectives tab for some of the Resource Programs (while leaving the rest of the tabs intact). My idea was to add a taxonomy term, categorize the relevant programs as such and then change the output based on that term.
It's a temporary sort of thing - eventually, the Instructions tab and the data outputted there will come back, so making a new content type or removing anything from the existing content isn't really an option (as far as I know).
Here's my code so far, from my theme's template.php file:
//builds the tabs
function nisenet_tabpage($element) {
$tabname = !empty($element['#tab_name']) ? $element['#tab_name'] : 'tabs-' . $element['#tabset_name'] . '-' . $element['#index'];
$output ='<div id="' . $tabname . '">';
$output .= '<h2 class="drupal-tabs-title"><a name="'. $tabname . '">'. $element['#title'] .'</a></h2>';
$output .= $element['#content'] . $element['#children'];
$output .='</div>';
return $output;
}
function nisenet_catalog_product_content($node) {
global $user;
drupal_add_js('misc/collapse.js');
$form = array();
$form['nisenet_catalog_content'] = array(
'#type' => 'tabset',
);
// my question - can I put an "if" here that will only run the following if/else code for nodes that do not have term ID 1008?
if ($node->type == 'resource_program' || $node->type == 'resource_forum') {
$form['nisenet_catalog_content']['instructions'] = array(
'#type' => 'tabpage',
'#title' => t('Instructions'),
'#content' => nisenet_catalog_build_instructions($node),
'#tab_name' => 'instructions',
);
}
else {
$form['nisenet_catalog_content']['instructions'] = array(
'#type' => 'tabpage',
'#title' => t('Objectives'),
'#content' => nisenet_catalog_build_objectives($node),
'#tab_name' => 'objectives',
);
}
// then other tabs get built, just like the ones above (minus the if/else)
return tabs_render($form);
}