From 6e344fd49cdaf55a21f1ff16bb312dcc897fbb78 Mon Sep 17 00:00:00 2001 From: David Rothstein Date: Tue, 6 Nov 2012 01:59:01 -0500 Subject: Issue #1154382 followup by plach: Fixed several issues with the newly-added hook_entity_view_mode_alter(). --- modules/taxonomy/taxonomy.module | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'modules/taxonomy') 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; -- cgit v1.2.3