You are here

function nd_terms_per_vocabulary in Node displays 7

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

Terms per vocabulary.

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

File

./nd.module, line 493
Node displays.

Code

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