diff --git a/views/addressfield.views.inc b/views/addressfield.views.inc index 77a5b45..4b99310 100644 --- a/views/addressfield.views.inc +++ b/views/addressfield.views.inc @@ -22,5 +22,39 @@ function addressfield_field_views_data($field) { } } + // Add a field definition/handler for each address component. + $properties = addressfield_data_property_info(); + foreach ($data as &$table) { + if ($field_def = $table[$field['field_name']]['field']) { + foreach ($table as $column_name => &$column) { + if (empty($column['field'])) { + + $column['field'] = $field_def; + $column['field']['handler'] = 'views_handler_field'; + $column['field']['real field'] = $column_name; + $column['field']['additional fields'] = array( + 'delta', + 'language', + 'bundle', + ); + + // Insert xNAL label from the address field data structure + // so users can distinguish them in listings (compared to the default + // behavior, which only shows the xNAL key). + $field_labels = field_views_field_label($field['field_name']); + $field_label = array_shift($field_labels); + $property = str_replace($field_def['field_name'] . '_', '', $column_name); + if (!empty($properties[$property])) { + $property_label = $properties[$property]['label']; + $title = t('@field-label - @property-label', array('@field-label' => $field_label, '@property-label' => $property_label)); + $column['title'] = $title; + $column['title short'] = $title; + } + + } + } + } + } + return $data; }