You are here

function spaces_taxonomy_get_term in Spaces 7.3

Searches the given node for a term reference that represents a space.

Parameters

object $node: A node object.

Return value

object|FALSE The term object that is referenced in the node, or FALSE if it was not found.

2 calls to spaces_taxonomy_get_term()
spaces_taxonomy_spaces_get_space_from_object in spaces_taxonomy/spaces_taxonomy.module
Implements hook_spaces_get_space_from_object().
space_taxonomy::router in spaces_taxonomy/plugins/space_taxonomy.inc
Override of router().

File

spaces_taxonomy/spaces_taxonomy.module, line 94
spaces_taxonomy.module

Code

function spaces_taxonomy_get_term($node) {
  $term = FALSE;
  $vocab = variable_get('spaces_taxonomy_machine_name', 0);
  $fields = field_info_fields();
  foreach ($fields as $name => $field) {
    if ($field['type'] == 'taxonomy_term_reference' && $vocab == $field['settings']['allowed_values'][0]['vocabulary']) {
      if (isset($node->{$name}['und'][0]['taxonomy_term'])) {
        $term = $node->{$name}['und'][0]['taxonomy_term'];
      }
      elseif (isset($node->{$name}['und'][0]['tid'])) {
        $term = taxonomy_term_load($node->{$name}['und'][0]['tid']);
      }
      break;
    }
  }
  return $term;
}