I'm using $location['country'] to output the country right now, but that only outputs the 2 letter abbreviation for the country. Does anyone know how I can output the full country name? Like 'United States' instead of 'us'.
Thanks.
I'm using $location['country'] to output the country right now, but that only outputs the 2 letter abbreviation for the country. Does anyone know how I can output the full country name? Like 'United States' instead of 'us'.
Thanks.
Comments
Comment #1
geodaniel commentedTo get the full country name of the US, for example, you could use:
Comment #2
(not verified) commentedComment #3
sodani commentedso can you tell me how this should be coded if I want to use the variable, $location['country'] instead of 'us' ? That code works specifically if I want to output 'United States' but not for outputting a variable. Apologies for the noobie php question.
Comment #4
geodaniel commentedI'm not sure which bit of code you're trying to change? Where is the display of 'us' that you want to change to the country name?
Comment #5
sodani commentedyou had pasted the following code:
which outputs 'United States'. I'd like the code to output the full name of whatever country is attached to that node. I assume that $country_names['us'] just needs to be changed so that the thing inside the brackets is a variable.
Also, do you happen to know how to manually output the entire location? I'm noticing that if I use contemplates, location doesn't get outputted unless you somehow tell it to.
Comment #6
bassio commentedadminister -> site configuration -> location settings -> display by default
Comment #7
bsuttis commentedI'm not finding the 'display by default' option at /admin/settings/location, was this feature removed? I'm using the latest dev of Location
Comment #8
bdragon commentedIn 3.x, $country_name is available.
Comment #9
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #10
Chad_Dupuis commentedYou can get the current country name from the url arguments. So assuming you have something like: http://yourhost.com/directory/us/CA/ you can use something like the following:
Where arg(0) would be "directory", arg(1) "us", and arg(2) "CA", etc.
Comment #11
summit commentedOn #8 (http://drupal.org/comment/reply/87296/1113108#comment-1052114) $country_name is added in 3.dev. Does this mean that this code works:
Thanks a lot in advance for your reply!
greetings,
Martijn