function node_view_multiple

You are here

7 node.module node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcode = NULL)
8 node.module node_view_multiple($nodes, $view_mode = 'teaser', $langcode = NULL)

Constructs a drupal_render() style array from an array of loaded nodes.

Parameters

$nodes: An array of nodes as returned by node_load_multiple().

$view_mode: View mode, e.g. 'full', 'teaser'...

$weight: An integer representing the weight of the first node in the list.

$langcode: (optional) A language code to use for rendering. Defaults to NULL which is the global content language of the current request.

Return value

An array in the format expected by drupal_render().

5 calls to node_view_multiple()
blog_page_last in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of all users.
blog_page_user in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of a given user.
node_page_default in modules/node/node.module
Menu callback: Generates a listing of promoted nodes.
node_show in modules/node/node.module
Generates an array which displays a node detail page.
taxonomy_term_page in modules/taxonomy/taxonomy.pages.inc
Menu callback; displays all nodes associated with a term.

File

modules/node/node.module, line 2666
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Code

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();
  foreach ($nodes as $node) {
    $build['nodes'][$node->nid] = node_view($node, $view_mode, $langcode);
    $build['nodes'][$node->nid]['#weight'] = $weight;
    $weight++;
  }
  $build['nodes']['#sorted'] = TRUE;
  return $build;
}

Comments

Is it possible to format data in table format using this api function, instead of teaser or pager... ?

The function returns a render array so yes you can add '#theme' => 'table' at the top level of the array. Just make sure you also add the other parameters that the theme function requires.

Good explanation of render arrays: https://drupal.org/node/930760

So you could render the return value as a table but you can't use this function directly to do it.