4

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;
}
  • Your Display settings for that node type (Default or Full page view) must not have the Title field outputted. The title field is usually outside the normal node render in those modes. Look at your page template, or node template, the title field is probably output separately. – Beebee Oct 18 '13 at 12:35
2

You could also try Page Preview, which shows a simulated full-page preview of a node:

This module re-implements the Preview area of the node edit form as an IFRAME that renders and displays the full page view of your edited content as the anonymous user would see it, including elements such as blocks that display as a reaction to the page context.

|improve this answer|||||
1

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

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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