You are here

function theme_node_preview in Drupal 6

Same name and namespace in other branches
  1. 4 modules/node.module \theme_node_preview()
  2. 5 modules/node/node.module \theme_node_preview()
  3. 7 modules/node/node.pages.inc \theme_node_preview()

Display a node preview for display during node creation and editing.

Parameters

$node: The node object which is being previewed.

Related topics

1 theme call to theme_node_preview()
node_preview in modules/node/node.pages.inc
Generate a node preview.

File

modules/node/node.pages.inc, line 421
Page callbacks for adding, editing, deleting, and revisions management for content.

Code

function theme_node_preview($node) {
  $output = '<div class="preview">';
  $preview_trimmed_version = FALSE;

  // Do we need to preview trimmed version of post as well as full version?
  if (isset($node->teaser) && isset($node->body)) {
    $teaser = trim($node->teaser);
    $body = trim(str_replace('<!--break-->', '', $node->body));

    // Preview trimmed version if teaser and body will appear different;
    // also (edge case) if both teaser and body have been specified by the user
    // and are actually the same.
    if ($teaser != $body || $body && strpos($node->body, '<!--break-->') === 0) {
      $preview_trimmed_version = TRUE;
    }
  }
  if ($preview_trimmed_version) {
    drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication.<span class="no-js"> You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.</span>'));
    $output .= '<h3>' . t('Preview trimmed version') . '</h3>';
    $output .= node_view(drupal_clone($node), 1, FALSE, 0);
    $output .= '<h3>' . t('Preview full version') . '</h3>';
    $output .= node_view($node, 0, FALSE, 0);
  }
  else {
    $output .= node_view($node, 0, FALSE, 0);
  }
  $output .= "</div>\n";
  return $output;
}