You are here

function entityreference_multiple_field_formatter_settings_summary in Entity reference multiple display 7

Implements hook_field_formatter_settings_summary().

File

./entityreference_multiple.module, line 144
Extend entity reference formatter with an option to separate elements display with specific view_modes.

Code

function entityreference_multiple_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = array();
  if ($display['type'] == 'entityreference_entity_multiple_view') {
    $entity_info = entity_get_info($field['settings']['target_type']);
    for ($i = 1; $i <= $settings['view_mode_number']; $i++) {
      $settings['view_mode_multiple']['view_mode_' . $i . '_number'] == '#' ? $num = t('all') : ($num = $settings['view_mode_multiple']['view_mode_' . $i . '_number']);
      if ($i > 1) {
        $num .= ' ' . t('next');
      }
      isset($entity_info['view modes'][$settings['view_mode_multiple']['view_mode_' . $i]]['label']) ? $mode = $entity_info['view modes'][$settings['view_mode_multiple']['view_mode_' . $i]]['label'] : ($mode = $entity_info['view modes']['full']['label']);
      if (!empty($settings['view_mode_multiple']['view_mode_' . $i . '_links'])) {
        $links = t('with');
      }
      else {
        $links = t('without');
      }
      $summary[] = t('Rendered !num as @mode @links links', array(
        '!num' => $num,
        '@mode' => $mode,
        '@links' => $links,
      ));
    }
  }
  return implode('<br />', $summary);
}