You are here

function taxonomy_get_statistics_field_value in Better Statistics 7

Returns the stats field value for a given field.

Parameters

string $field: The name of the field for which a value should be returned.

Return value

mixed The value of the stats field specified, or NULL if none could be found.

See also

node_better_statistics_fields()

1 string reference to 'taxonomy_get_statistics_field_value'
taxonomy_better_statistics_fields in modules/taxonomy.statistics.inc
Implements hook_better_statistics_fields().

File

modules/taxonomy.statistics.inc, line 182
Statistics API functions and hooks for the Taxonomy module.

Code

function taxonomy_get_statistics_field_value($field) {
  $term = function_exists('menu_get_object') ? menu_get_object('taxonomy_term', 2) : NULL;
  switch ($field) {
    case 'taxonomy_page_tid':
      return isset($term->tid) ? $term->tid : NULL;
      break;
    case 'taxonomy_page_term_name':
      return isset($term->name) ? $term->name : NULL;
      break;
    case 'taxonomy_page_vid':
      return isset($term->vid) ? $term->vid : NULL;
      break;
    case 'taxonomy_page_vocab_machine_name':
      return isset($term->vocabulary_machine_name) ? $term->vocabulary_machine_name : NULL;
      break;
    case 'taxonomy_tids':
      $node = function_exists('menu_get_object') ? menu_get_object('node') : NULL;
      if (isset($node->type)) {
        return implode(',', better_statistics_get_entity_terms('node', $node->type, $node));
      }
      break;
  }
  return NULL;
}