You are here

function nd_terms_per_vocabulary in Display Suite 6.3

Terms per vocabulary.

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

File

modules/nd/nd.module, line 669
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)];
    $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;
}