diff --git a/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php b/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php index 4ff6df9..d2fd278 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php @@ -17,7 +17,7 @@ class PathTaxonomyTermTest extends PathTestBase { * * @var array */ - public static $modules = array('taxonomy', 'views'); + public static $modules = array('taxonomy'); public static function getInfo() { return array( diff --git a/core/modules/taxonomy/config/install/entity.view_mode.taxonomy_term.full.yml b/core/modules/taxonomy/config/install/entity.view_mode.taxonomy_term.full.yml index 50b1854..bb8c47e 100644 --- a/core/modules/taxonomy/config/install/entity.view_mode.taxonomy_term.full.yml +++ b/core/modules/taxonomy/config/install/entity.view_mode.taxonomy_term.full.yml @@ -1,6 +1,6 @@ id: taxonomy_term.full label: 'Taxonomy term page' -status: false +status: true cache: true targetEntityType: taxonomy_term dependencies: diff --git a/core/modules/taxonomy/config/install/views.view.taxonomy_term.yml b/core/modules/taxonomy/config/install/views.view.taxonomy_term.yml index 6477894..74116df 100644 --- a/core/modules/taxonomy/config/install/views.view.taxonomy_term.yml +++ b/core/modules/taxonomy/config/install/views.view.taxonomy_term.yml @@ -2,7 +2,7 @@ base_field: nid base_table: node core: '8' description: 'Content belonging to a certain taxonomy term.' -status: false +status: true display: default: id: default @@ -175,7 +175,21 @@ display: links: true comments: false provider: views - header: { } + header: + entity_taxonomy_term: + id: entity_taxonomy_term + table: views + field: entity_taxonomy_term + relationship: none + group_type: group + admin_label: '' + empty: false + tokenize: 1 + entity_id: '!1' + view_mode: full + bypass_access: 0 + plugin_id: entity + provider: views footer: { } empty: { } relationships: { } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php index 9dba1eb..b8f5b0e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php @@ -83,13 +83,13 @@ public function termTitle(TermInterface $taxonomy_term) { * @return \Symfony\Component\HttpFoundation\Response * A response object. */ - public function termFeed(TermInterface $term) { - $channel['link'] = $this->url('taxonomy.term_page', array('taxonomy_term' => $term->id()), array('absolute' => TRUE)); - $channel['title'] = \Drupal::config('system.site')->get('name') . ' - ' . $term->label(); + public function termFeed(TermInterface $taxonomy_term) { + $channel['link'] = $this->url('taxonomy.term_page', array('taxonomy_term' => $taxonomy_term->id()), array('absolute' => TRUE)); + $channel['title'] = \Drupal::config('system.site')->get('name') . ' - ' . $taxonomy_term->label(); // Only display the description if we have a single term, to avoid clutter and confusion. // HTML will be removed from feed description. - $channel['description'] = check_markup($term->description->value, $term->format->value, '', TRUE); - $nids = taxonomy_select_nodes($term->id(), FALSE, \Drupal::config('system.rss')->get('items.limit')); + $channel['description'] = check_markup($taxonomy_term->description->value, $taxonomy_term->description->format, '', TRUE); + $nids = taxonomy_select_nodes($taxonomy_term->id(), FALSE, \Drupal::config('system.rss')->get('items.limit')); return node_feed($nids, $channel); } diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index f1db93f..132cab9 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -16,6 +16,7 @@ use Drupal\taxonomy\Entity\Vocabulary; use Drupal\taxonomy\VocabularyInterface; use Drupal\Component\Utility\String; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; /** * Denotes that no term in the vocabulary has a parent. @@ -134,6 +135,36 @@ function taxonomy_term_uri($term) { } /** + * Implements hook_page_build(). + */ +function taxonomy_page_build(&$page) { + if (\Drupal::request()->attributes->get(RouteObjectInterface::ROUTE_NAME) == 'taxonomy.term_page') { + $term = \Drupal::request()->attributes->get('taxonomy_term'); + foreach ($term->uriRelationships() as $rel) { + // Set the term path as the canonical URL to prevent duplicate content. + $page['#attached']['drupal_add_html_head_link'][] = array( + array( + 'rel' => $rel, + 'href' => $term->url($rel), + ), + TRUE, + ); + + if ($rel == 'canonical') { + // Set the non-aliased canonical path as a default shortlink. + $page['#attached']['drupal_add_html_head_link'][] = array( + array( + 'rel' => 'shortlink', + 'href' => $term->url($rel, array('alias' => TRUE)), + ), + TRUE, + ); + } + } + } +} + +/** * Return nodes attached to a term across all field instances. * * This function requires taxonomy module to be maintaining its own tables, diff --git a/core/modules/taxonomy/taxonomy.routing.yml b/core/modules/taxonomy/taxonomy.routing.yml index 5c2aaad..d533544 100644 --- a/core/modules/taxonomy/taxonomy.routing.yml +++ b/core/modules/taxonomy/taxonomy.routing.yml @@ -90,7 +90,7 @@ taxonomy.overview_terms: taxonomy.term_page: path: '/taxonomy/term/{taxonomy_term}' defaults: - _entity_view: 'taxonomy_term.view' + _entity_view: 'taxonomy_term.full' _title: 'Taxonomy term' _title_callback: '\Drupal\taxonomy\Controller\TaxonomyController::termTitle' requirements: