You are here

function tvi_get_term_info in Taxonomy Views Integrator 6

Same name and namespace in other branches
  1. 7 tvi.module \tvi_get_term_info()

Returns different data sets with the term, view, and settings information for a specified term id.

1 call to tvi_get_term_info()
tvi_get_view_info in ./tvi.module
Returns information about the term, view, and settings found for the arguments given to the taxonomy term callback.

File

./tvi.module, line 295
Enables use of views for taxonomy pages.

Code

function tvi_get_term_info($tid, $type = TVI_DATATYPE_VIEW) {
  static $term_info = array();
  if (!array_key_exists($tid, $term_info)) {
    $term = taxonomy_get_term($tid);

    // Try using term and vocabulary overrides.
    tvi_include('query');
    $settings = tvi_load_settings($term->tid, TVI_TYPE_TERM, FALSE);
    if (!$settings || !$settings->status) {

      // Then vocabulary override.
      $settings = tvi_load_settings($term->vid, TVI_TYPE_VOCAB, FALSE);
    }
    if ($settings && $settings->view_name) {
      $view = views_get_view($settings->view_name);
    }
    $term_info[$tid] = array(
      'term' => $term,
      'settings' => $settings,
      'view' => $view,
    );
  }
  switch ($type) {
    case TVI_DATATYPE_ALL:
      return (object) $term_info[$tid];
    case TVI_DATATYPE_TERM:
      return $term_info[$tid]['term'];
    case TVI_DATATYPE_VIEW:
      return $term_info[$tid]['view'];
    case TVI_DATATYPE_SETTINGS:
      return $term_info[$tid]['settings'];
  }
  return NULL;
}