diff options
author | David Rothstein <drothstein@gmail.com> | 2012-11-06 01:59:01 -0500 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2012-11-06 01:59:01 -0500 |
commit | 6e344fd49cdaf55a21f1ff16bb312dcc897fbb78 (patch) | |
tree | 6791c741a95e9ef9cc7acb03cb85d9403668fc1a /modules/taxonomy | |
parent | 6b11350d32b753a45f4814325bdcd8aafd163050 (diff) | |
download | brdo-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.module | 20 |
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; |