2

When I preview a node before creating it I get this message:

'The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication. You can insert the delimiter "<!--break-->" (without the quotes) to fine-tune where your post gets split.'

And I also get a trimmed and full version in the preview. This has no relivance for my site and is actually quite confusing. How can I remove it?

I dont want to hide the message with CSS (as in the linked method) as im assuming other messages can be shown in the same div. How to hide the "trimmed version" from the preview page?

Ive tried removing the teaser display for the content type under 'custom display settings'.

The field is a text area, not a text area with summary.

Ive tried using the String Overrides module.

Ive tried this theme function but it didnt do anything. http://drupal.org/node/1355962

2 Answers 2

2

Ah, the linked template.php override method (code below) does work but you need a sub theme for it to do so.

/**
 * Override node preview to remove trimmed teaser version.
 */
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;
}

UPDATE this has stopped working for me. It seems the code doenst work properly with my zen template.

UPDATE This code worked for me:

            /**
             * Returns HTML for a node preview for display during node creation and editing.
             *
             * @param $variables
             *   An associative array containing:
             *   - node: The node object which is being previewed.
             *
             * @ingroup themeable
             */
            function THEMENAME_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;
            }
1
  • This definitely works. I found it here too: drupal.org/node/1782016 in case someone wants to dig into someone else's issue.
    – Big Robots
    Commented Mar 8, 2013 at 21:30
0

Here's a slightly better version, which will execute more quickly because it doesn't render the node twice. Put the following in the template.php file of your theme, renaming the function to match your theme name:

/**
 * Returns HTML for a node preview for display during node creation and editing.
 * Customized version removes the trimmed/teaser version and any links from the     preview
 *
 * @param $variables
 *   An associative array containing:
 *   - node: The node object which is being previewed.
 *
 * @see node_preview()
 * @ingroup themeable
 */
function THEMENAME_node_preview($variables) {
  $node = $variables['node'];

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

  $output .= '<h3>' . t('Preview full version') . '</h3>';

  $elements = node_view($node, 'full');
  unset($elements['links']);  //this is optional, but I think links are distracting when previewing a node
  $output .= drupal_render($elements);
  $output .= "</div>\n";

  return $output;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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