Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I upgraded to Alpha 6 yesterday but just noticed that the location field I have set for my content type is not appearing when I go to Manage Fields. I noticed this while looking into another problem.. it appears that the Views address field puts the postal code infront of the city. For example, it is displaying an address as:
123 Main St
10453 New York City, NY
The biggest issue here is that when I try to add a new location it does not get added to my Gmap. I'm wondering if the backwards postal code is causing that problem?
Comment | File | Size | Author |
---|---|---|---|
#20 | location-zipcode-fix-1943912-20-D7.patch | 1.23 KB | Michael-IDA |
#17 | location-zipcode-fix-1943912-17.patch | 957 bytes | SeanA |
Comments
Comment #1
dmcgrew CreditAttribution: dmcgrew commentedAlright, ignore the thing about the locations not being added to the Gmap. Apparently that was just some fluke (i hope). Everything else (the postal code, and content type field) are still broke though.
Comment #2
podarok#1 please. update summary for latest status
Comment #3
Neograph734The module generates a php error here:
PHP Fatal error: Class 'DrupalWebTestCase' not found in /home/.../sites/all/modules/location/tests/location_testcase.php on line 8
Comment #4
podarok#3 look at #1947990: drush cc all fails due to testclass loading by migrate module
Comment #5
hvasconcelos CreditAttribution: hvasconcelos commentedI have tried both Alpha6 and Alpha8 version and experienced the same issue with the ZIP code showing up before the city and state.
Here's the patch for it, it worked for me. Make sure to clear the cache.
Comment #6
Jerenus CreditAttribution: Jerenus commentedComment #7
podarokComment #8
venutip CreditAttribution: venutip commentedJust want to point out to others reading this issue that you don't need a patch to move the ZIP, as this is all happening at the theme level. All you have to do is:
1. Copy `location.tpl.php` from the Location module's root directory into your theme.
2. Edit the file and move the ZIP.
3. Clear cache.
While I'm here though, I can say that the patch does move the ZIP :)
Comment #9
hvasconcelos CreditAttribution: hvasconcelos commentedHey @venutip, that would work as well, thanks for sharing! I don't believe we should be having to do any of this in the first place, so the module must be problematic. Hopefully they will fix it on the next update.
@podarok, I am not aware whether that's an international standard, but I do know that at least in Brazil we show the ZIP code in the end of the address, too. So, I'm assuming it's not a standard.
Comment #10
dpovshed CreditAttribution: dpovshed commentedRecently I had the same task formatting US address. Solution in #8 works for me!
About committing patch to the core - I did a small research and it looks that most popular place for ZIP is right before country name. However many european country like Italy or Belgium have postcode before site name.
Attention to @podarok:
This means if we silently move a zipcode we may introduce bugs for all existing users in several countries, which is not an option. So I vote for:
- keep current placement;
- close this issue as 'Work as designed';
- we have nice recipe as well as patch for cases where we need ZIP in different place.
For those who interested - here is one of resources to take a look at national samples - http://www.addressdoctor.com/en/countries-data/address-formats.html
Comment #11
tgriswold CreditAttribution: tgriswold commentedI had the same issue and also used #8 to solve it.
A bit more detail for those who may be timid about trying this.
print $province_print;
) assuming you want the zip/postal code after the province (state) field.If you have a need to turn it off for whatever reason, just change the name of the file you modified to something like `location.tpl.php.OLD` and the system will ignore the one you put in the theme and use the default one that is in the Location directory.
As for making this a core change, I would lean to adding some kind of easy configuration option that would allow the admin to select where the Postal Code displays. A bit of a pain, but I don’t think it should be necessary to modify code and drop things into modules to accommodate something as common as displaying Postal Code location. Of course I am not the one doing the work, so you can factor that in to the value of my opinion.
Thanks to venutip for a clean solution and to all for their assistance and feedback.
Comment #12
System Lord CreditAttribution: System Lord commented#8 via #11 worked great from me. Although, my first line for the code began at 16. Just fyi for others. I would also agree with #11...
Thank you
Comment #13
medialantern CreditAttribution: medialantern commentedI disagree with #1943912-10: Patch - ZIP Code showing in the wrong place. I believe the change that switched this postal code location should be reverted. Then, either the technique outlined above in #1943912-8: Patch - ZIP Code showing in the wrong place should be recommended for OTHER countries, or a proper fix implemented.
Somebody is going to break, because there is no universal solution. But I think a more rational choice for WHO should break should be based on something like population counts (# of mailing addresses likely to be affected), not gut instincts. Of the 10 most populous countries in the world (China, India, USA, Indonesia, Brazil, Pakistan, Nigeria, Bangladesh, Russia, and Japan), only China and Nigera have addresses where the postal code comes first. Moreover, this change a) doesn't even get Nigeria's correct, anyway, and b) neither before/after properly format China's (in fact, some PRC addresses are more complex than the Location module can even handle internally).
Deliberately breaking the vast majority of the world population's address formats until a more configurable "fix" can be implemented is the wrong approach, IMHO. Having that same group be the ones who need to implement the fix is also wrong.
Disclaimer: I reside in one of the 10 most populous countries. I do not believe that makes the opinion wrong.
Comment #14
RWill CreditAttribution: RWill commented#8 worked for me.
Comment #15
ak55 CreditAttribution: ak55 commented#8 worked for me too. Thanks!
Comment #16
Michael-IDA CreditAttribution: Michael-IDA commentedPer the logic in #13 this should have been fixed two years ago, not just left in limbo.
Switching back to needs review.
Comment #17
SeanA CreditAttribution: SeanA commentedPatch against latest dev.
Putting the postal code after the province probably covers the vast majority of users, but many countries in Europe do put the postal code before the city/locality. More information about international address formats: http://www.bitboost.com/ref/international-address-formats.html
Comment #18
Michael-IDA CreditAttribution: Michael-IDA commented+1, Works on an ugly multi-site.
But . . .
Your code is too well formatted. I get:
"Boston , MA 02108"
The extra space is coming from the print $city; /span> having white space between it and the print ', ';
I'd say I'll submit a patch, but . . . Holidays will probably nix that.
Best,
Michael
Comment #19
SeanA CreditAttribution: SeanA commentedThe extra whitespace is/was already present in the tpl file. Needs work. =/
Comment #20
Michael-IDA CreditAttribution: Michael-IDA as a volunteer commentedPatched against version = "7.x-3.7" (same as dev for location.tpl.php)
Incorporating patch from #17, added cleanup of whitespace.
Comment #21
podarokThanks, merged.
Comment #24
hockey2112 CreditAttribution: hockey2112 commentedWas this actually committed to 7.x-3.7? I am experiencing this issue on my website as well.
"90210 Beverly Hills, CA" instead of "Beverly Hills, CA 90210"
-------
Sorry, I misunderstood the prior post. I do see that this has not been committed to 7.x-3.7. I applied the patch and it worked great. Thanks!