You are here

function spaces_core_taxonomy in Spaces 5

Same name and namespace in other branches
  1. 5.2 spaces_core/spaces_core.module \spaces_core_taxonomy()

Page call back to handle taxonomy listing

If a term is requested in a group context we use a group aware page when then term's vocabulary is related to any group targeted node types. If it is from a vocab that doesn't relate to any group aware content or is request outsite of a group contexts we use a group agnostic listing.

Parameters

$tid: The term id to generate a listing page for.

Return value

A themed taxonomy listing page.

1 string reference to 'spaces_core_taxonomy'
spaces_core_menu in spaces_core/spaces_core.module
Implementation of hook_menu()

File

spaces_core/spaces_core.module, line 248

Code

function spaces_core_taxonomy($tid) {
  if (is_numeric($tid) && ($t = taxonomy_get_term($tid))) {
    $v = taxonomy_get_vocabulary($t->vid);

    // Test the vocabulary to see if it is related to group content or not.
    $use_gid = false;
    if ($gid = spaces_gid()) {
      foreach ($v->nodes as $type) {
        if (!og_is_omitted_type($type)) {
          $use_gid = true;
          break;
        }
      }
    }
  }
  if ($use_gid) {
    $view = views_get_view('spaces_taxonomy');
    $content = views_build_view('page', $view, array(
      $gid,
      $tid,
    ), true, 25);
  }
  else {
    $view = views_get_view('spaces_taxonomy');
    $content = views_build_view('page', $view, array(
      0,
      $tid,
    ), true, 25);
  }
  if (is_object($t) && is_object($v)) {
    drupal_set_title($v->name . ': ' . $t->name);

    // set taxonomy context
    context_set('taxonomy', array(
      'vid' => $t->vid,
      'tid' => $t->tid,
    ));
    if ($use_gid) {
      context_set('taxonomy', 'group_vocab', true);
    }
  }
  return $content;
}