Same name and namespace in other branches
  1. 4.7.x includes/theme.inc \theme_node()
  2. 5.x includes/theme.inc \theme_node()
  3. 6.x developer/theme.php \theme_node()

Return a themed node.

Parameters

$node: An object providing all relevant information for displaying a node:

  • $node->nid: The ID of the node.
  • $node->type: The content type (story, blog, forum...).
  • $node->title: The title of the node.
  • $node->created: The creation date, as a UNIX timestamp.
  • $node->teaser: A shortened version of the node body.
  • $node->body: The entire node contents.
  • $node->changed: The last modification date, as a UNIX timestamp.
  • $node->uid: The ID of the author.
  • $node->username: The username of the author.

$teaser: Whether to display the teaser only, as on the main page.

$page: Whether to display the node as a standalone page. If TRUE, do not display the title because it will be provided by the menu system.

Return value

A string containing the node output.

Related topics

2 theme calls to theme_node()
fileupload_view in developer/examples/fileupload.module
node_view in modules/node.module
Generate a display of the given node.

File

includes/theme.inc, line 512
The theme system, which controls the output of Drupal.

Code

function theme_node($node, $teaser = FALSE, $page = FALSE) {
  if (module_exist('taxonomy')) {
    $terms = taxonomy_link('taxonomy terms', $node);
  }
  if ($page == 0) {
    $output = '<h2 class="title">' . check_plain($node->title) . '</h2> by ' . format_name($node);
  }
  else {
    $output = 'by ' . format_name($node);
  }
  if (count($terms)) {
    $output .= ' <small>(' . theme('links', $terms) . ')</small><br />';
  }
  if ($teaser && $node->teaser) {
    $output .= $node->teaser;
  }
  else {
    $output .= $node->body;
  }
  if ($node->links) {
    $output .= '<div class="links">' . theme('links', $node->links) . '</div>';
  }
  return $output;
}