Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $nids = array(123,456,789);
- $nodes = node_load_multiple($nids);
- foreach ($nodes as $node) {
- $node_view = node_view($node, 'teaser');
- $output .= drupal_render($node_view);
- }
- $build['nodes']['#markup'] = $output;
- return $build;
- $nodes = Drupal::entityManager()->getStorage('node')->loadMultiple($nids);
- // Or a use the static loadMultiple method on the entity class:
- $nodes = DrupalnodeEntityNode::loadMultiple($nids);
- // And then you can view/build them all together:
- $build = Drupal::entityManager()->viewMultiple($nodes, 'teaser');
- $render_controller = Drupal::entityTypeManager->getViewBuilder($entity->getEntityTypeId());
- $render_output = $render_controller->view($entity, $view_mode, $langcode);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement