You are here

class taxonomy_CrumbsMultiPlugin_termParent in Crumbs, the Breadcrumbs suite 7

Same name and namespace in other branches
  1. 7.2 plugins/crumbs.taxonomy.inc \taxonomy_CrumbsMultiPlugin_termParent

Hierarchy

Expanded class hierarchy of taxonomy_CrumbsMultiPlugin_termParent

File

plugins/crumbs.taxonomy.inc, line 164

View source
class taxonomy_CrumbsMultiPlugin_termParent implements crumbs_MultiPlugin {
  function describe($api) {
    foreach (taxonomy_get_vocabularies() as $voc_id => $voc) {
      $api
        ->addRule($voc->machine_name, 'Vocabulary: ' . $voc->name);
    }

    // Now set a generic title for the entire plugin.
    $api
      ->addRule('*', t('Set taxonomy/term/123 as the parent for taxonomy/term/456, if 123 is the parent term of 456.'));
  }

  /**
   * Terms get their parent terms as breadcrumb parent.
   * The method name matches the router path "taxonomy/term/%".
   */
  function findParent__taxonomy_term_x($path, $item) {
    $term = $item['map'][2];

    // Load the term if it hasn't been loaded due to a missing wildcard loader.
    $term = is_numeric($term) ? taxonomy_term_load($term) : $term;
    $parents = taxonomy_get_parents($term->tid);
    $result = array();
    foreach ($parents as $parent_tid => $parent_term) {
      if ($parent_term->vocabulary_machine_name == $term->vocabulary_machine_name) {
        $uri = entity_uri('taxonomy_term', $parent_term);
        if (!empty($uri)) {
          return array(
            $term->vocabulary_machine_name => $uri['path'],
          );
        }
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
taxonomy_CrumbsMultiPlugin_termParent::describe function Overrides crumbs_MultiPlugin::describe
taxonomy_CrumbsMultiPlugin_termParent::findParent__taxonomy_term_x function Terms get their parent terms as breadcrumb parent. The method name matches the router path "taxonomy/term/%".