node_build_content($node, $view_mode = 'full')Builds a structured array representing the node's content.
The content built for the node (field values, comments, file attachments or other node components) will vary depending on the $view_mode parameter.
Drupal core defines the following view modes for nodes, with the following default use cases:
If search.module is enabled:
If book.module is enabled:
Contributed modules might define additional view modes, or use existing view modes in additional contexts.
$node A node object.
$view_mode View mode, e.g. 'full', 'teaser'...
modules/node/node.module, line 1250
<?php
function node_build_content($node, $view_mode = 'full') {
// Remove previously built content, if exists.
$node->content = array();
// The 'view' hook can be implemented to overwrite the default function
// to display nodes.
if (node_hook($node, 'view')) {
$node = node_invoke($node, 'view', $view_mode);
}
// Build fields content.
// In case of a multiple view, node_view_multiple() already ran the
// 'prepare_view' step. An internal flag prevents the operation from running
// twice.
field_attach_prepare_view('node', array($node->nid => $node), $view_mode);
entity_prepare_view('node', array($node->nid => $node));
$node->content += field_attach_view('node', $node, $view_mode);
// Always display a read more link on teasers because we have no way
// to know when a teaser view is different than a full view.
$links = array();
if ($view_mode == 'teaser') {
$links['node_readmore'] = array(
'title' => t('Read more'),
'href' => 'node/' . $node->nid,
'attributes' => array('rel' => 'tag', 'title' => strip_tags($node->title))
);
}
$node->content['links']['node'] = array(
'#theme' => 'links__node',
'#links' => $links,
'#attributes' => array('class' => array('links', 'inline')),
);
// Allow modules to make their own additions to the node.
module_invoke_all('node_view', $node, $view_mode);
}
?>