Posted by rbl on June 5, 2010 at 8:38am
3 followers
Jump to:
| Project: | Addresses |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Hi!
One of the biggest problems I'm having now is that provinces and countries are often output in their 2 letter codes and I need their full names.
I thought that theme_addresses_country($afields['country'], 'name') would be the way to go but when I use theme_addresses_country and theme_addresses_province, there's no output.
How can I do this?
Thanks!
Ricardo
Comments
#1
Any information on this, I am trying to do something similar combining the addresses module and computed_fields module.
Thanks
Justin
#2
@rbl
Ok, I looked a little more into this, and came up with a solution for my problem, which may be applicable to your problem. I will start by saying I am new to php and modules so I am sure there is a better way.
I am using the computed_field module to pull individual address information (ie country) out of the addresses module to display in a table via views2, I am wanting the 3 digit country code. I ended up creating a custom module with the following code in mymodule.module
function mymodule_addresses_country($country) {// Load addresses.inc from addresses module
module_load_include('inc', 'addresses');
$country = check_plain($country);
if (!empty($country)) {
$countries_code3 = _addresses_country_get_code3();
// return data as all caps
return drupal_strtoupper($countries_code3[$country]);
}
}
I got most of this from addresses.inc around line 742.
Then using the computed_field module I create a CCK field type computed
Computed Code:
$node_field[0]['value'] = $node->field_address[0]['country'];Display Format:
$country = $node_field_item['value'];if (function_exists(mymodule_addresses_country)){
$display = drupal_strtoupper(mymodule_addresses_country($country));
}
else {
$display = $node_field_item['value'];
}
if anyone has a better approach I would appreciate it.
Thanks
Justin
#3
Hmmm...
In Administer » Site configuration » Addresses, do you know of Format fieldset where you can edit the output of country you want to fix?
Did you try to use the [addresses_country_code3_hcard] token in your cards? Or are those not available in the CCK fields and you're trying to use those fields?
You also have [addresses_country_code2_hcard]. And for the province (state) you have [addresses_province_name_hcard] or [addresses_province_code_hcard].
Again, I think that does not work with the CCK fields, but I did not see anything about CCK in the first post.
Thank you.
Alexis
#4
Justin,
I feel kinda stupid to point the obvious but have you looked into the "display fields" page of that content type?
If not go to /admin/content/node-type/[your-content-type]/display and there you can choose some different formats to display addresses
info.
Alexis,
My problem would be solved if there were more display options besides the ones there, as in some fields I'm using addresses to store just one element, like the country name for example (in opposition to a full address or a combination of elements like state + country)
I trying to go around it at template level but it would be better if there were more display formats.
Ricardo
#5
rbl,
At this point I have not been able to make the CCK field work on my test system. I have no clue why... So I cannot really develop anything for CCK.
Thank you.
Alexis