summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/taxonomy/taxonomy.api.php6
-rw-r--r--modules/taxonomy/taxonomy.module6
-rw-r--r--modules/taxonomy/taxonomy.pages.inc22
-rw-r--r--modules/taxonomy/taxonomy.test4
4 files changed, 23 insertions, 15 deletions
diff --git a/modules/taxonomy/taxonomy.api.php b/modules/taxonomy/taxonomy.api.php
index 10575c5..5667eb9 100644
--- a/modules/taxonomy/taxonomy.api.php
+++ b/modules/taxonomy/taxonomy.api.php
@@ -184,9 +184,9 @@ function hook_taxonomy_term_delete($term) {
/**
* Act on a taxonomy term that is being assembled before rendering.
*
- * The module may add elements to $term->content prior to rendering. This hook
- * will be called after hook_view(). The structure of $term->content is a
- * renderable array as expected by drupal_render().
+ * The module may add elements to $term->content prior to rendering. The
+ * structure of $term->content is a renderable array as expected by
+ * drupal_render().
*
* @param $term
* The term that is being assembled for rendering.
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 905923d..9be7dfc 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -762,7 +762,7 @@ function taxonomy_term_show($term) {
* @param $view_mode
* View mode, e.g. 'full', 'teaser'...
* @param $weight
- * An integer representing the weight of the first node in the list.
+ * An integer representing the weight of the first taxonomy term in the list.
* @param $langcode
* (optional) A language code to use for rendering. Defaults to the global
* content language of the current request.
@@ -819,7 +819,7 @@ function taxonomy_term_build_content($term, $view_mode = 'full', $langcode = NUL
);
drupal_alter('entity_view_mode', $view_mode, $context);
- // Try to add in the core taxonomy pieces like description and nodes.
+ // Add the term description if the term has one and it is visible.
$type = 'taxonomy_term';
$entity_ids = entity_extract_ids($type, $term);
$settings = field_view_mode_settings($type, $entity_ids[2]);
@@ -869,7 +869,7 @@ function taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL) {
$langcode = $GLOBALS['language_content']->language;
}
- // Populate $node->content with a render() array.
+ // Populate $term->content with a render() array.
taxonomy_term_build_content($term, $view_mode, $langcode);
$build = $term->content;
diff --git a/modules/taxonomy/taxonomy.pages.inc b/modules/taxonomy/taxonomy.pages.inc
index 4d2c4e6..299c7bb 100644
--- a/modules/taxonomy/taxonomy.pages.inc
+++ b/modules/taxonomy/taxonomy.pages.inc
@@ -14,7 +14,9 @@
* The page content.
*/
function taxonomy_term_page($term) {
- // Assign the term name as the page title.
+ // If there is a menu link to this term, the link becomes the last part of
+ // the active trail, and the link name becomes the page title. Thus, we must
+ // explicitly set the page title to be the term title.
drupal_set_title($term->name);
// Build breadcrumb based on the hierarchy of the term.
@@ -33,17 +35,23 @@ function taxonomy_term_page($term) {
drupal_set_breadcrumb($breadcrumb);
drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name);
- // If there is a menu link to this term, the link becomes the last part of
- // the active trail, and the link name becomes the page title. Thus, we must
- // explicitly set the page title to be the node title.
- $uri = entity_uri('taxonomy_term', $term);
-
// Set the term path as the canonical URL to prevent duplicate content.
+ $uri = entity_uri('taxonomy_term', $term);
drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
// Set the non-aliased path as a default shortlink.
drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
- $build = taxonomy_term_show($term);
+ // Normally we would call taxonomy_term_show() here, but for backwards
+ // compatibility in Drupal 7 we do not want to do that (it produces different
+ // data structures and HTML markup than what Drupal 7 released with). Calling
+ // taxonomy_term_view() directly provides essentially the same thing, but
+ // allows us to wrap the rendered term in our desired array structure.
+ $build['term_heading'] = array(
+ '#prefix' => '<div class="term-listing-heading">',
+ '#suffix' => '</div>',
+ 'term' => taxonomy_term_view($term, 'full'),
+ );
+
if ($nids = taxonomy_select_nodes($term->tid, TRUE, variable_get('default_nodes_main', 10))) {
$nodes = node_load_multiple($nids);
$build += node_view_multiple($nodes);
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 4cfb81b..123bdce 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -1428,8 +1428,8 @@ class TaxonomyHooksTestCase extends TaxonomyWebTestCase {
// hook_entity_view() are invoked.
$term = taxonomy_term_load($term->tid);
$term_build = taxonomy_term_page($term);
- $this->assertFalse(empty($term_build['taxonomy_terms'][$term->tid]['taxonomy_test_term_view_check']), 'hook_taxonomy_term_view() was invoked when viewing the term.');
- $this->assertFalse(empty($term_build['taxonomy_terms'][$term->tid]['taxonomy_test_entity_view_check']), 'hook_entity_view() was invoked when viewing the term.');
+ $this->assertFalse(empty($term_build['term_heading']['term']['taxonomy_test_term_view_check']), 'hook_taxonomy_term_view() was invoked when viewing the term.');
+ $this->assertFalse(empty($term_build['term_heading']['term']['taxonomy_test_entity_view_check']), 'hook_entity_view() was invoked when viewing the term.');
// Delete the term.
taxonomy_term_delete($term->tid);