function text_field_formatter_view
Implements hook_field_formatter_view().
File
-
modules/
field/ modules/ text/ text.module, line 259
Code
function text_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'text_default':
case 'text_trimmed':
foreach ($items as $delta => $item) {
$output = _text_sanitize($instance, $langcode, $item, 'value');
if ($display['type'] == 'text_trimmed') {
$output = text_summary($output, $instance['settings']['text_processing'] ? $item['format'] : NULL, $display['settings']['trim_length']);
}
$element[$delta] = array(
'#markup' => $output,
);
}
break;
case 'text_summary_or_trimmed':
foreach ($items as $delta => $item) {
if (!empty($item['summary'])) {
$output = _text_sanitize($instance, $langcode, $item, 'summary');
}
else {
$output = _text_sanitize($instance, $langcode, $item, 'value');
$output = text_summary($output, $instance['settings']['text_processing'] ? $item['format'] : NULL, $display['settings']['trim_length']);
}
$element[$delta] = array(
'#markup' => $output,
);
}
break;
case 'text_plain':
foreach ($items as $delta => $item) {
$element[$delta] = array(
'#markup' => strip_tags($item['value']),
);
}
break;
}
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.