You are here

function nd_terms_per_vocabulary in Node displays 6.2

Same name and namespace in other branches
  1. 6.3 nd.module \nd_terms_per_vocabulary()
  2. 7 nd.module \nd_terms_per_vocabulary()

Terms per vocabulary.

1 string reference to 'nd_terms_per_vocabulary'
nd_theme in ./nd.module
Implementation of hook_theme().

File

./nd.module, line 702
Node displays.

Code

function nd_terms_per_vocabulary($field) {
  $content = '';
  if (isset($field['object']->taxonomy) && !empty($field['object']->taxonomy)) {
    $terms = array();
    $key_elements = explode('_', $field['key']);
    $vid = end($key_elements);
    $formatter_explode = explode('_', $field['formatter']);
    $separators = array(
      'space' => ' ',
      'comma' => ', ',
    );
    $separator = $separators[end($formatter_explode)];
    $list = end($formatter_explode) == 'list' ? TRUE : FALSE;
    $linked = prev($formatter_explode);
    foreach ($field['object']->taxonomy as $tid => $term) {
      if ($term->vid == $vid) {
        $terms[] = $linked == 'linked' ? l($term->name, taxonomy_term_path($term)) : check_plain($term->name);
      }
    }
    if (!empty($terms)) {
      if ($separator) {
        $content = implode($separator, $terms);
      }
      elseif ($list) {
        $content = theme('item_list', $terms);
      }
    }
  }
  return $content;
}