diff options
author | David Rothstein <drothstein@gmail.com> | 2014-11-01 17:31:26 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2014-11-01 17:31:26 -0400 |
commit | c312e5ee5589d060601f633deba3be26df494815 (patch) | |
tree | 0db9e745cdbefcec1cb9d6453669139901bf9546 /modules/node/node.module | |
parent | 5aede0dadeb785ca30f5e16c6d67281286a047ee (diff) | |
download | brdo-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/node/node.module')
-rw-r--r-- | modules/node/node.module | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/modules/node/node.module b/modules/node/node.module index acca83ecb..e5b716630 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1397,12 +1397,7 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) { $node->content = array(); // Allow modules to change the view mode. - $context = array( - 'entity_type' => 'node', - 'entity' => $node, - 'langcode' => $langcode, - ); - drupal_alter('entity_view_mode', $view_mode, $context); + $view_mode = key(entity_view_mode_prepare('node', array($node->nid => $node), $view_mode, $langcode)); // The 'view' hook can be implemented to overwrite the default function // to display nodes. @@ -2664,15 +2659,26 @@ function node_feed($nids = FALSE, $channel = array()) { * An array in the format expected by drupal_render(). */ function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcode = NULL) { - field_attach_prepare_view('node', $nodes, $view_mode, $langcode); - entity_prepare_view('node', $nodes, $langcode); $build = array(); + $entities_by_view_mode = entity_view_mode_prepare('node', $nodes, $view_mode, $langcode); + foreach ($entities_by_view_mode as $entity_view_mode => $entities) { + field_attach_prepare_view('node', $entities, $entity_view_mode, $langcode); + entity_prepare_view('node', $entities, $langcode); + + foreach ($entities as $entity) { + $build['nodes'][$entity->nid] = node_view($entity, $entity_view_mode, $langcode); + } + } + foreach ($nodes as $node) { - $build['nodes'][$node->nid] = node_view($node, $view_mode, $langcode); $build['nodes'][$node->nid]['#weight'] = $weight; $weight++; } + // Sort here, to preserve the input order of the entities that were passed to + // this function. + uasort($build['nodes'], 'element_sort'); $build['nodes']['#sorted'] = TRUE; + return $build; } |