function theme_node_preview

7.x theme_node_preview($variables)
5.x node.module theme_node_preview($node)
6.x theme_node_preview($node)

Returns HTML for a node preview for display during node creation and editing.


$variables: An associative array containing:

  • node: The node object which is being previewed.

See also


Related topics

1 theme call to theme_node_preview()
node_preview in drupal/modules/node/
Generates a node preview.
5 string references to the theme hook from theme_node_preview()

Note: this list is generated by looking for the string for this theme hook, so it may include some references that are not actually using this theme hook.

node_form in drupal/modules/node/
Form constructor for the node add/edit form.
node_form_build_preview in drupal/modules/node/
Form submission handler for node_form().
node_theme in drupal/modules/node/node.module
Implements hook_theme().
node_type_form in drupal/modules/node/
Form constructor for the node type editing form.
node_update_7004 in drupal/modules/node/node.install
Extend the existing default preview and teaser settings to all node types.


drupal/modules/node/, line 422
Page callbacks for adding, editing, deleting, and revisions management for content.


function theme_node_preview($variables) {
  $node = $variables['node'];

  $output = '<div class="preview">';

  $preview_trimmed_version = FALSE;

  $elements = node_view(clone $node, 'teaser');
  $trimmed = drupal_render($elements);
  $elements = node_view($node, 'full');
  $full = drupal_render($elements);

  // Do we need to preview trimmed version of post as well as full version?
  if ($trimmed != $full) {
    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 .= $trimmed;
    $output .= '<h3>' . t('Preview full version') . '</h3>';
    $output .= $full;
  else {
    $output .= $full;
  $output .= "</div>\n";

  return $output;