Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. $nids = array(123,456,789);
  2. $nodes = node_load_multiple($nids);
  3. foreach ($nodes as $node) {
  4. $node_view = node_view($node, 'teaser');
  5. $output .= drupal_render($node_view);
  6. }
  7. $build['nodes']['#markup'] = $output;
  8. return $build;
  9.  
  10. $nodes = Drupal::entityManager()->getStorage('node')->loadMultiple($nids);
  11. // Or a use the static loadMultiple method on the entity class:
  12. $nodes = DrupalnodeEntityNode::loadMultiple($nids);
  13.  
  14. // And then you can view/build them all together:
  15. $build = Drupal::entityManager()->viewMultiple($nodes, 'teaser');
  16.  
  17. $render_controller = Drupal::entityTypeManager->getViewBuilder($entity->getEntityTypeId());
  18. $render_output = $render_controller->view($entity, $view_mode, $langcode);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement