Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I know how to override the preview of a node being edited, but for some reason in the "trimmed" portion it displays a node's title and in the "full" version only the body. I'd like to be able to display the node's title in the "full" version also.

The theme method I'm overriding is theme_node_preview($variables).

I'm actually removing the "trimmed" portion completely, since it's not relevant to my content types. The method looks something like:

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

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

  $preview_trimmed_version = FALSE;

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

  $output .= $full;
  $output .= "</div>\n";

  return $output;
}
share|improve this question

1 Answer

This is my version of previewing the node, could be useful (ctools version):

function foo_preview_node($form, $form_state) {
  $node = clone ctools_object_cache_get('foo', 'node'); // get the latest node object from the cache
  $node->in_preview = TRUE;
  _field_invoke_multiple('load', 'node', array(NULL => $node)); // additional stuff from other modules
  field_attach_prepare_view('node', array(NULL => &$node), 'full'); // lets field types and formatters load additional data needed for display
  $build = @node_view($node, 'full');
  $form['preview'] = array(
      '#type' => 'item',
      // '#title' => 'optional title',
      '#markup' => drupal_render($build),
  );
  return $form;

}

See: http://drupal.org/node/1622952

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.