Hi,

Bit of a simple one perhaps. I am using a view to display the body summary and a thumbnail. I want to only display the summary if the summary field has been populated, NOT have an auto-trimmed version of the body display. Is there a way to do this, turn off the auto body trim feature, without having to create a new field (and then have to mess about display settings etc)

Thanks

Mike

Comments

bohemier’s picture

Here's how I did it:

Add the body field
Formatter: Default (doesn't really matter)
Style: Nothing Checked here except Add Default Classes
Rewrite results: Rewrite the output of this field: [field_body-summary]
Rewrite results: Convert newlines to HTML
tags if you wish to
No results behavior: Nothing checked

That should it... cheers!

J-F Bohémier
Angelicode.com

michaelmallett’s picture

Thankyou very much!

brentg’s picture

Other solution to use this on manage display: custom formatter, here's some quick example code

<?php
/**
 * Implements hook_field_formatter_info().
 */
function my_module_field_formatter_info() {
  return array(
    'summary_only_formatter' => array(
      'label' => t('Summary only'),
      'field types' => array('text_with_summary'),
    ),
  );
}

/**
 * Implements hook_field_formatter_view().
 */
function my_module_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  switch ($display['type']) {
    case 'summary_only_formatter':
      $element = array();
      foreach ($items as $item){
        if (isset($item['summary']) && !empty($item['summary'])) {
            $element[]['#markup'] = $item['summary'];
        }
      }
      return $element;
      break;
  }
}
?>