When you enable "full address" in the node views its formatted as follows:
street, zip code
city, state
instead of
street,
city, state, zip
also, i'm not sure where i can change the format of the 'province/state' field to use the code instead of the full name
Comments
Comment #1
swentel commentedYou can use a theme override of the 'theme_nd_location_address' function, that way, you can choose how you want to output the full address.
Comment #2
bewhy commentedsorry, I don't speak themer :) . . . I went into the nd.tpl.php file and re-ordered the fields in the address array. I came away with two problems:
1. I'd actually like to change it from province name to province code
2. the postal code isn't showing (as it was with the previous order)
So, i'm sure more information about this "theme overide" would help a bit.
(ps. I''ve changed this to a support request because simply there's actually nothing wrong with the code, but 'wrong' with the formatting of the [american] address)
Comment #3
bewhy commentedComment #4
swentel commentedOk, what you'll need todo is this: open template.php and copy the whole 'theme_nd_location_address' to this file. You need to rename the function to phptemplate_nd_location_address. You'll need to rebuild the cache. More info about theming overrides is found at http://drupal.org/node/173880.
Comment #5
swentel commentedComment #6
bewhy commentedi'm pretty sure that i followed your instructions to the 't'. . . but then I got a white screen, yes, even when clearing the caches.
I think it would be easier for everybody (including myself) if the default was properly formatted instead of having to create work-arounds for it to display as one would expect it to (and I promise I had no intention to sound snarky or smart-mouthed in that statement)
Comment #7
bewhy commentedthanks for not letting me be lazy. . . I'm not sure if what i did is exactly kosher, but it works. This is exactly what I have in my template.php file now (yes, without the php tags):
and it outputs this:
1439 South Street, Philadelphia Pennsylvania, 19146
instead of
1439 South Street, Philadelphia Pennsylvania, 19146
now I need to figure out how to shorten the province name to the province code
Comment #8
bewhy commentedquick question though, how does one change the output of the province name to province code?
Comment #9
swentel commentedDon't know it by heart exactly, but what you can do is this:
You need to install the devel module for dsm to work. I'm not sure if the province code is inside the location object, if not, you'll have to load it via the location_province_name($country, $province) function.
Comment #10
swentel commentedComment #11
bradezone commentedI was curious about this too. I tweaked my theme function as follows:
function mytheme_nd_location_address($field) {
return check_plain($field['object']->location['street']) . '<br />'
. check_plain($field['object']->location['city']) . ', '
. check_plain($field['object']->location['province_name']) . ' '
. check_plain($field['object']->location['postal_code']);
}
Just curious why such an odd order is used as the default? Is there some country where postal code comes before the city?
Comment #12
victoriachan commentedThis is really an issue with nd_contrib. See http://drupal.org/node/900612
Comment #13
ryanfc78 commentedI ran into this same issue and found a "easier" fix than this patch. Just go to location.tpl.php in the Location folder under Modules. Around line 16 you will see the postal code followed by city and province. Jut copy the lines of code for postal_code and move it below Province.
So it looked like this:
and I changed it to this:
This will put the postal code after the state/province.
Comment #14
tbw17 commentedThank you #13, simple solution and much appreciated!
Comment #15
schmook commented#13 is a good solution. Thanks!
Just a note: you should move location.tpl.php to your theme directory. Otherwise, if you update the module in the future it will be overwritten.
Comment #16
bstrange commented@schmook, while it is a good idea to put this in your theme directory; one would think that eventually they'd fix it... yet a year since your post and it's still there... go figure.
For me, I'd assume 'update' would include fixing the glaring layout error akin to putting the area code after the phone number :P
Gosh, I'm cranky tonight, guess I'm just irritated I am back on this thread years after the first time I came across this bug, don't mind me ;)
Comment #17
joyv commentedAs a newbie, when I move this to the theme directory should I create a folder called "location" or where should I place it?
I am also running Omega 4 if that has an impact.
UPDATE: For Omega 4 place the file in the "Templates" directory of your theme and create a subfolder "Location" to help keep the files organized. Worked perfect!
Comment #18
dkhill commentedI am using the Garland theme, so I copied it to the root folder of my garland directory theme and the issue was resolved. The only thing else I was trying to do is move the "additional" field to fall right under the location name.
I guess I'll have to play with this piece of code.
Thanks for sharing this!
Comment #19
JimJS commentedUsing logical operators to add the zip code to the proper location worked for me.
if (!empty($postal_code) && strtoupper($country) !== 'US'):
- and -
if (!empty($postal_code) && strtoupper($country) === 'US'):
I also had some format problems because of the use of class="region" in the printing of the $province variable. It appears that my theme use "region" as a class in many instances. By changing this to something else like "province-region" it kept the zip code in a proper order. I also looked at the location module's css and it did not have any instances of ".region".