/ Published in: PHP
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
function _phptemplate_variables($hook, $vars) {
switch ($hook) {
case 'page':
/* Get the taxonomy info from the current node while in the page */
$node_taxonomy_object = $vars['node']->taxonomy;
/* make sure the taxonomy object exists to prevent errors */
if ($node_taxonomy_object) {
foreach($node_taxonomy_object as $term) {
/* only use selected vocabulary IDs to generate classes -- lists these below (1, and 21 are just examples) */
switch($term->vid) {
case 3:
/*In Print*/
$vars['body_id'] = 'media';
$vars['body_class'] = 'in-print';
break;
// case 1:
/*Issues*/
/* $vars['body_id'] = 'policy';
$vars['body_class'] = 'issues';
break; */
case 6:
/*Multimedia*/
$vars['body_id'] = 'media';
$vars['body_class'] = 'multimedia';
break;
case 2:
/*Publication*/
$vars['body_id'] = 'media';
$vars['body_class'] = 'publication-archive';
break;
case 9:
/*Other Media*/
$vars['body_id'] = 'media';
break;
case 10:
/*Other Media*/
$vars['body_id'] = 'outreach';
break;
case 11:
/*Analysis*/
$vars['body_id'] = 'analysis';
break;
case 14;
$test = arg(2);
if (!arg(3)) {
$id = $var['node']->nid;
$terms = taxonomy_node_get_terms_by_vocabulary($id, 14);
foreach ($terms as $t) {
$termID = $t->tid;
$intBody = $t->name;
}
//get parents
$parents = taxonomy_get_parents($termID);
foreach ($parents as $parent){
$vars['body_id']=$parent->name;
}
}
case 8:
/* build the $body_class from the term's name, replacing spaces with "-" */
/* build the $body_ID from the term's vocabulary name, replacing spaces with "-"
$vocabulary_array = taxonomy_get_vocabulary($term->vid);
$vars['body_id'] = str_replace(" ","-",$vocabulary_array->name);*/
break;
default:
$vars['body_class'] = 'none';
}
}
}
break;
}
return $vars;
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                