// Allow modules to make their own additions to the comment.
module_invoke_all('comment_view', $comment, $view_mode, $langcode);
module_invoke_all('entity_view', $comment, 'comment', $view_mode, $langcode);
+
+ // Make sure the current view mode is stored if no module has already
+ // populated the related key.
+ $comment->content += array('#view_mode' => $view_mode);
}
/**
// Allow modules to make their own additions to the node.
module_invoke_all('node_view', $node, $view_mode, $langcode);
module_invoke_all('entity_view', $node, 'node', $view_mode, $langcode);
+
+ // Make sure the current view mode is stored if no module has already
+ // populated the related key.
+ $node->content += array('#view_mode' => $view_mode);
}
/**
$this->assertText('Extra data that should appear only in the teaser for the node.', 'Teaser text present');
// Make sure body text is not present.
$this->assertNoText('Data that should appear only in the body for the node.', 'Body text not present');
+
+ // Test that the correct build mode has been set.
+ $build = node_view($node);
+ $this->assertEqual($build['#view_mode'], 'teaser', 'The view mode has correctly been set to teaser.');
}
}
// 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);
// 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);
}
/**
$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;
// Populate $account->content with a render() array.
module_invoke_all('user_view', $account, $view_mode, $langcode);
module_invoke_all('entity_view', $account, 'user', $view_mode, $langcode);
+
+ // Make sure the current view mode is stored if no module has already
+ // populated the related key.
+ $account->content += array('#view_mode' => $view_mode);
}
/**