summaryrefslogtreecommitdiff
path: root/modules/taxonomy
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2012-11-06 01:59:01 -0500
committerDavid Rothstein <drothstein@gmail.com>2012-11-06 01:59:01 -0500
commit6e344fd49cdaf55a21f1ff16bb312dcc897fbb78 (patch)
tree6791c741a95e9ef9cc7acb03cb85d9403668fc1a /modules/taxonomy
parent6b11350d32b753a45f4814325bdcd8aafd163050 (diff)
downloadbrdo-6e344fd49cdaf55a21f1ff16bb312dcc897fbb78.tar.gz
brdo-6e344fd49cdaf55a21f1ff16bb312dcc897fbb78.tar.bz2
Issue #1154382 followup by plach: Fixed several issues with the newly-added hook_entity_view_mode_alter().
Diffstat (limited to 'modules/taxonomy')
-rw-r--r--modules/taxonomy/taxonomy.module20
1 files changed, 12 insertions, 8 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index dc3cf44bc..905923dbf 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -811,6 +811,14 @@ function taxonomy_term_build_content($term, $view_mode = 'full', $langcode = NUL
// Remove previously built content, if exists.
$term->content = array();
+ // Allow modules to change the view mode.
+ $context = array(
+ 'entity_type' => 'taxonomy_term',
+ 'entity' => $term,
+ 'langcode' => $langcode,
+ );
+ drupal_alter('entity_view_mode', $view_mode, $context);
+
// Try to add in the core taxonomy pieces like description and nodes.
$type = 'taxonomy_term';
$entity_ids = entity_extract_ids($type, $term);
@@ -836,6 +844,10 @@ function taxonomy_term_build_content($term, $view_mode = 'full', $langcode = NUL
// Allow modules to make their own additions to the taxonomy term.
module_invoke_all('taxonomy_term_view', $term, $view_mode, $langcode);
module_invoke_all('entity_view', $term, 'taxonomy_term', $view_mode, $langcode);
+
+ // Make sure the current view mode is stored if no module has already
+ // populated the related key.
+ $term->content += array('#view_mode' => $view_mode);
}
/**
@@ -857,14 +869,6 @@ function taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL) {
$langcode = $GLOBALS['language_content']->language;
}
- // Allow modules to change the view mode.
- $context = array(
- 'entity_type' => 'taxonomy_term',
- 'entity' => $term,
- 'langcode' => $langcode,
- );
- drupal_alter('entity_view_mode', $view_mode, $context);
-
// Populate $node->content with a render() array.
taxonomy_term_build_content($term, $view_mode, $langcode);
$build = $term->content;