custom/taxonomy_helper/taxonomy_helper_node/taxonomy_helper_node.module, line 116
taxonomy_helper_node_vocabularies_output($node, $teaser = FALSE)Output a node's vocabularies group by vocabulary with a customized display and terms formatting.
$node A node object
$teaser Boolean to indicate whether to return the teaser or page output of the node's terms.
NULL if the default formatting should be used, an empty string if hidden, and finally the re-formatted node terms grouped by vocabulary.
<?php
function taxonomy_helper_node_vocabularies_output($node, $teaser = FALSE) {
// Add css
drupal_add_css(drupal_get_path('module', 'taxonomy_helper_node') .'/taxonomy_helper_node.css');
$display = ($teaser) ? 'teaser' : 'page';
// Get cache
$cached = taxonomy_helper_node_cache_get($node, $display);
if ($cached !== NULL) {
return $cached;
}
// Default settings
if ($teaser) {
$display_default_type = variable_get('taxonomy_helper_node_default_teaser_display', TAXONOMY_HELPER_NODE_DISPLAY_INLINE);
$terms_default_type = variable_get('taxonomy_helper_node_default_teaser_terms', TAXONOMY_HELPER_NODE_TERMS_DELIMITED);
}
else {
$display_default_type = variable_get('taxonomy_helper_node_default_page_display', TAXONOMY_HELPER_NODE_DISPLAY_BLOCK);
$terms_default_type = variable_get('taxonomy_helper_node_default_page_terms', TAXONOMY_HELPER_NODE_TERMS_LINK);
}
// Return NULL if node has no taxonomy terms or use default term display.
if (!$node->taxonomy || TAXONOMY_HELPER_NODE_DISPLAY_DEFAULT) {
return NULL;
}
// Return an empty string if terms are hidden.
if ($display_default_type == TAXONOMY_HELPER_NODE_DISPLAY_HIDDEN) {
return '';
}
// Loop and format the node's vocabularies.
$output = '';
$vocabularies = taxonomy_get_vocabularies($node->type);
foreach ($vocabularies as $vocabulary) {
// Get vocab type
$display_type = variable_get('taxonomy_helper_node_'. $vocabulary->vid .'_'. $display .'_display', $display_default_type);
if ($display_type == TAXONOMY_HELPER_NODE_DISPLAY_DEFAULT) {
$display_type = $display_default_type;
}
// Get terms type
$terms_type = variable_get('taxonomy_helper_node_'. $vocabulary->vid .'_'. $display .'_terms', $term_default_type);
if ($terms_type == TAXONOMY_HELPER_NODE_TERMS_DEFAULT) {
$terms_type = $terms_default_type;
}
// Get node's vocabulary output.
$output .= taxonomy_helper_node_vocabulary_output($node, $vocabulary, $display_type, $terms_type);
}
// Wrap output with div
if ($output != '') {
$output = '<div class="taxonomy-helper-node-terms">'. $output .'</div>';
}
// Set output in cache
taxonomy_helper_node_cache_set($node, $display, $output);
return $output;
}
?>