diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermBreadcrumbBuilder.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermBreadcrumbBuilder.php new file mode 100644 index 0000000..f6e2b0f --- /dev/null +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermBreadcrumbBuilder.php @@ -0,0 +1,38 @@ +id())) { + $current = array_shift($parents); + $breadcrumb[] = l($current->label(), 'taxonomy/term/' . $current->id()); + } + $breadcrumb[] = l(t('Home'), NULL); + $breadcrumb = array_reverse($breadcrumb); + + return $breadcrumb; + } + } +} diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc index 93f628d..526ac7d 100644 --- a/core/modules/taxonomy/taxonomy.pages.inc +++ b/core/modules/taxonomy/taxonomy.pages.inc @@ -19,17 +19,6 @@ function taxonomy_term_page(Term $term) { // Assign the term name as the page title. drupal_set_title($term->label()); - // @todo This overrides any other possible breadcrumb and is a pure hard-coded - // presumption. Make this behavior configurable per vocabulary or term. - $breadcrumb = array(); - $current = $term; - while ($parents = taxonomy_term_load_parents($current->id())) { - $current = array_shift($parents); - $breadcrumb[] = l($current->label(), 'taxonomy/term/' . $current->id()); - } - $breadcrumb[] = l(t('Home'), NULL); - $breadcrumb = array_reverse($breadcrumb); - drupal_set_breadcrumb($breadcrumb); drupal_add_feed('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->label()); foreach ($term->uriRelationships() as $rel) { diff --git a/core/modules/taxonomy/taxonomy.services.yml b/core/modules/taxonomy/taxonomy.services.yml index 265eb5d..02dda09 100644 --- a/core/modules/taxonomy/taxonomy.services.yml +++ b/core/modules/taxonomy/taxonomy.services.yml @@ -4,3 +4,7 @@ services: arguments: ['@plugin.manager.entity'] tags: - { name: access_check } + taxonomy_term.breadcrumb: + class: Drupal\taxonomy\TermBreadcrumbBuilder + tags: + - { name: breadcrumb_builder, priority: 1002 }