You are here

function _custom_breadcrumbs_taxonomy_term_trail in Custom Breadcrumbs 6.2

Same name and namespace in other branches
  1. 7.2 custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.inc \_custom_breadcrumbs_taxonomy_term_trail()

Generates the taxonomy term trail.

Parameters

$tid: A taxonomy term id.

$is_term_page: TRUE if the breadcrumb is being prepared for the taxonomy term page, FALSE otherwise.

$objs: An optional array of objects to be used to determine breadcrumb visibility and for token replacement.

$types: An array of token types to be used in token replacement.

$part: A postive integer indicating the breadcrumb segment (home crumb = 0).

Return value

The breadcrumb trail.

1 call to _custom_breadcrumbs_taxonomy_term_trail()
custom_breadcrumbs_taxonomy_generate_breadcrumb in custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.inc
Generates a breadcrumb from the taxonomy hierarchy of the term id or vocab id. This will only be called if custom_breadcrumbs_taxonomy_use_hierarchy has been enabled.

File

custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.inc, line 368
Helper functions for custom_breadcrumbs_taxonomy.

Code

function _custom_breadcrumbs_taxonomy_term_trail($tid, $is_term_page = FALSE, $objs = array(), $types = array(
  'global' => NULL,
), $part = 1) {

  // Generate the TERM breadcrumb.
  $trail = array();
  $parent_terms = array_reverse(taxonomy_get_parents_all($tid));
  foreach ($parent_terms as $parent_term) {
    $breadcrumbs = custom_breadcrumbs_load_breadcrumbs('custom_breadcrumbs_taxonomy', 'custom_breadcrumbs_taxonomy_term', array(
      'tid' => $parent_term->tid,
    ));
    $term_path = NULL;
    $title = NULL;
    $bid = NULL;
    if ($breadcrumb = custom_breadcrumbs_select_breadcrumb($breadcrumbs, $objs)) {
      $term_path = $breadcrumb->paths;
      $title = $breadcrumb->titles;
      $bid = $breadcrumb->bid;
      if (module_exists('token')) {
        $term_path = token_replace_multiple($term_path, $types);
        $title = token_replace_multiple($title, $types);
      }
    }
    if ($title == NULL) {
      $title = _custom_breadcrumbs_taxonomy_tt("taxonomy:term:{$parent_term->tid}:name", $parent_term->name);
    }
    if ($term_path == NULL) {
      $term_path = taxonomy_term_path(taxonomy_get_term($parent_term->tid));
    }

    // Do not create links to own self if we are on a taxonomy/term page.
    if ($is_term_page && $parent_term->tid == $tid) {
      $trail[] = check_plain($title);
    }
    else {
      $options = _custom_breadcrumbs_identifiers_option($part, $bid);
      $trail[] = l($title, $term_path, $options);
    }
    ++$part;
  }
  return $trail;
}