summaryrefslogtreecommitdiff
path: root/modules/taxonomy
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2014-11-01 17:31:26 -0400
committerDavid Rothstein <drothstein@gmail.com>2014-11-01 17:31:26 -0400
commitc312e5ee5589d060601f633deba3be26df494815 (patch)
tree0db9e745cdbefcec1cb9d6453669139901bf9546 /modules/taxonomy
parent5aede0dadeb785ca30f5e16c6d67281286a047ee (diff)
downloadbrdo-c312e5ee5589d060601f633deba3be26df494815.tar.gz
brdo-c312e5ee5589d060601f633deba3be26df494815.tar.bz2
Issue #1968348 by znerol, David_Rothstein, peximo, DuaelFr: Fixed hook_field_formatter_prepare_view does not make use of hook_entity_view_mode_alter causing major errors.
Diffstat (limited to 'modules/taxonomy')
-rw-r--r--modules/taxonomy/taxonomy.module24
1 files changed, 15 insertions, 9 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 4191146a4..e147c1cab 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -776,15 +776,26 @@ function taxonomy_term_show($term) {
* An array in the format expected by drupal_render().
*/
function taxonomy_term_view_multiple($terms, $view_mode = 'teaser', $weight = 0, $langcode = NULL) {
- field_attach_prepare_view('taxonomy_term', $terms, $view_mode, $langcode);
- entity_prepare_view('taxonomy_term', $terms, $langcode);
$build = array();
+ $entities_by_view_mode = entity_view_mode_prepare('taxonomy_term', $terms, $view_mode, $langcode);
+ foreach ($entities_by_view_mode as $entity_view_mode => $entities) {
+ field_attach_prepare_view('taxonomy_term', $entities, $entity_view_mode, $langcode);
+ entity_prepare_view('taxonomy_term', $entities, $langcode);
+
+ foreach ($entities as $entity) {
+ $build['taxonomy_terms'][$entity->tid] = taxonomy_term_view($entity, $entity_view_mode, $langcode);
+ }
+ }
+
foreach ($terms as $term) {
- $build['taxonomy_terms'][$term->tid] = taxonomy_term_view($term, $view_mode, $langcode);
$build['taxonomy_terms'][$term->tid]['#weight'] = $weight;
$weight++;
}
+ // Sort here, to preserve the input order of the entities that were passed to
+ // this function.
+ uasort($build['taxonomy_terms'], 'element_sort');
$build['taxonomy_terms']['#sorted'] = TRUE;
+
return $build;
}
@@ -817,12 +828,7 @@ function taxonomy_term_build_content($term, $view_mode = 'full', $langcode = NUL
$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);
+ $view_mode = key(entity_view_mode_prepare('taxonomy_term', array($term->tid => $term), $view_mode, $langcode));
// Add the term description if the term has one and it is visible.
$type = 'taxonomy_term';