diff --git nd_location/nd_location.module nd_location/nd_location.module index 24277ce..6693ad5 100644 --- nd_location/nd_location.module +++ nd_location/nd_location.module @@ -477,23 +477,25 @@ function theme_nd_location_directions($field) { * Combine all address fields. */ function theme_nd_location_address($field) { + // Get the location field settings for this node type + $settings = variable_get('location_settings_node_'. $field['object']->type, array()); + + // Loop through and collect the address fields we want to output in the order specified in node location settings, + // and check that they are not set to be hidden in node location setting + // also ignore arrays (eg. locpick) $address = array(); - if (!empty($field['object']->location)) { - if (!empty($field['object']->location['street'])) { - $address[] = check_plain($field['object']->location['street']); - } - $fullcity = array(); - if (!empty($field['object']->location['postal_code'])) { - $fullcity[] = check_plain($field['object']->location['postal_code']); - } - if (!empty($field['object']->location['city'])) { - $fullcity[] = check_plain($field['object']->location['city']); - } - $address[] = implode($fullcity, ' '); - if (!empty($field['object']->location['province_name'])) { - $address[] = check_plain($field['object']->location['province_name']); + foreach ($settings['form']['fields'] as $fieldname => $fieldsettings) { + if (!$settings['display']['hide'][$fieldname] && !empty($field['object']->location[$fieldname]) && !is_array($field['object']->location[$fieldname])) { + // Replace country code with full country name + if ($fieldname == 'country') { + module_load_include('inc', 'location', 'location'); + $field['object']->location[$fieldname] = location_country_name($field['object']->location[$fieldname]); + } + // Add this field to our array of fields to output + $address[] = check_plain($field['object']->location[$fieldname]); } } + return implode($address, ', '); }