You are here

function template_preprocess_field_group_multiple_label_value in Field group multiple 7

Same name and namespace in other branches
  1. 7.x theme.inc \template_preprocess_field_group_multiple_label_value()

File

./theme.inc, line 250
Theme functions for field_group_multiple

Code

function template_preprocess_field_group_multiple_label_value(&$variables) {
  drupal_add_css(drupal_get_path('module', 'field_group_multiple') . '/field_group_multiple.css');
  $group = $variables['group'];
  $fields = $variables['fields'];
  $items = $variables['items'];
  $field_name_label = $group->format_settings['instance_settings']['label_value_field'];
  $arr_label = array(
    $field_name_label,
  );
  $diff = array_diff($group->children, $arr_label);
  $field_name_value = array_shift($diff);
  $tmp_entry = $fields[$field_name_value];
  unset($tmp_entry['#items']);

  // unset other children
  foreach (element_children($tmp_entry, TRUE) as $nr) {
    unset($tmp_entry[$nr]);
  }
  $entries = array();
  foreach (element_children($items, TRUE) as $delta) {
    $values = $items[$delta];
    $entry = $tmp_entry;
    $entry['#title'] = $values[$field_name_label]['#markup'];
    $entry['#items'][0] = $entry[0] = $values[$field_name_value];
    $entries[$delta] = $entry;
  }
  $variables['entries'] = $entries;
  if (empty($entries)) {
    $variables['is_empty'] = TRUE;
  }
  else {
    $variables['is_empty'] = FALSE;
  }
  $suggestions_prefix = 'field_group_multiple_label_value';
  $variables['theme_hook_suggestions'] = _template_field_group_multiple_suggestions($suggestions_prefix, $group);
}