I'm migrating a client's website to Drupal 7 using Migrate. I'm trying to export address fields to .csv using views. In a user view, i see the following tokens but they just won't print.

Can someone help me figure what it is I'm missing?

[field_address_country] == Content: Mailing Address (field_address)
[field_address_aname] == Content: Mailing Address (field_address)
[field_address_is_primary] == Content: Mailing Address (field_address)
[field_address_phone] == Content: Mailing Address (field_address)
[field_address_city] == Content: Mailing Address (field_address)
[field_address_street] == Content: Mailing Address (field_address)
[field_address_additional] == Content: Mailing Address (field_address)
[field_address_province] == Content: Mailing Address (field_address)
[field_address_fax] == Content: Mailing Address (field_address)
[field_address_postal_code] == Content: Mailing Address (field_address)

Thanks!

Comments

bisonbleu’s picture

Title: Can't display phone/fax in views » Can't single out address sub-fields such as street, city in views

Well, I spent too many hours trying to display Addresses' sub-fields - and I just couldn't.

Then I came across this comment and was finally able to break the darn Addresses data into its sub-fields. Works great. Nice trick that might come in handy in other similar situations.

In short add the Mailing Address field and exclude it from the display. Then add a Customfield of type PHP code and set its value to something like this.

<?php echo $data->node_data_field_address_field_address_street; ?>

To figure out the exact naming scheme of the sub-field use the print_r function.

<pre><?php echo $data; ?></pre>

Ant this is what you'll get.

	.stdClass Object
	(
		[nid] => 251
		[node_users__users_uid] => 49
		[node_data_field_address_field_address_is_primary] => 
		[node_data_field_address_field_address_aname] => 
		[node_data_field_address_field_address_country] => ca
		[node_data_field_address_field_address_province] => QC
		[node_data_field_address_field_address_city] => SomeCity,
		[node_data_field_address_field_address_street] => 1255 Some Street
		[node_data_field_address_field_address_additional] => 
		[node_data_field_address_field_address_postal_code] => H0H 0H0
		[node_data_field_address_field_address_phone] => 514-123-4567
		[node_data_field_address_field_address_fax] => 514-123-6789
		[node_language] => en
		[node_type] => profile
		[node_vid] => 251
	)

Hope this is helpful.