This bug applies to both 5.x-2.7 and 5.x-3.0-test3

In the theme_location function (5.x-2.7), or location.tpl.php file (5.x-3.0-test3), the line for
implode(', ', $city_province_postal);
should be moved above the postal code part, and then output the postal code. This way, you won't add an extra comma between the state/province and the postal. For instance, you want to say "San Jose, CA 95128". But currently, it outputs "San Jose, CA, 95128".

Comments

yesct’s picture

Status: Active » Postponed (maintainer needs more info)

Could some confirm this extra comma is still in the latest dev versions?

And if it is, making a patch would really help to evaluate/get this committed. To make a patch, you make a copy of the file (or directory structure) then make changes in one (or more) of the files, and then run diff on the two files, the output of diff is the patch... here is a better description of how to make a patch: http://drupal.org/patch/create

I'll mark this postponed, needs more info, for now.

tonycpsu’s picture

StatusFileSize
new861 bytes

The extra comma is still there in 6.x-3.x-dev. Here's a patch.

yesct’s picture

Status: Postponed (maintainer needs more info) » Needs review

could someone try this patch on their 6.x-3.x-dev version. if this works, please change the status to RTBC, reviewed and tested by the community. does this patch also apply to the 5.x branch? someone could try that too.

tonycpsu’s picture

I have not tried it on 5.x, as I only have 6.x available now.

axolx’s picture

This is a tpl file. You can override it in your theme. Just clone location.tpl.php to your theme's dir, make the desired changes, and clear the cache to that the new template file makes it to the theme registry.

mrtoner’s picture

Status: Needs review » Reviewed & tested by the community

Tested on dev. BTW, Addresses has a nifty address formats feature that, along with Token, allows you to define how addresses should display for various countries.

jonathan_hunt’s picture

The patch in #2 will leave a dangling comma if $city exists but none of $province or $postal_code. I'm using the following right now:

  if ($city || $province || $postal_code) {
    $city_province_postal = array();

    if ($city) {
      $city_province_postal[] = '<span class="locality">'. $city .'</span>';
    }

    if (!empty($province) && !empty($postal_code)) {
      $city_province_postal[] = '<span class="region">'. $province .'</span> <span class="postal-code">'. $postal_code .'</span>';
    }
    else {
      if ($province) {
        $city_province_postal[] = '<span class="region">'. $province .'</span>';
      }
      if ($postal_code) {
        $city_province_postal[] = '<span class="postal-code">'. $postal_code .'</span>';
      }
    }

    echo implode(', ', $city_province_postal);
  }
yesct’s picture

Status: Reviewed & tested by the community » Needs work

needs #7 to be rolled as a patch.

yesct’s picture

there is a good chance of getting some things committed, if a patch can be re-rolled to match the new 6.x-dev version (http://drupal.org/project/location)

mikeytown2’s picture

Version: 5.x-2.7 » 6.x-3.x-dev
Component: User interface » Code
Status: Needs work » Needs review
StatusFileSize
new1.18 KB

#7 as a patch

SeanA’s picture

StatusFileSize
new955 bytes

Here's what I'm using, it's a bit more efficient and understandable IMO. Applies to both 6.x-dev and 5.x-dev.

yesct’s picture

tagging

yesct’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new951 bytes

reviewing

current behavior:
city, zip
zip
state, zip
state
city, state
city, state, zip
city

after patching:
city zip
zip
state zip
state
city, state
city, state zip
city

sooo the only change is
city, zip -> city zip
state, zip -> state zip
city, state, zip -> city state zip

I think most can agree
city, state, zip -> city state zip
is the improvement looked for

and
state, zip -> state zip
is probably wanted too

I think it is questionable what to do about
city zip
should be OK

fwiw, the us post office asks for NO commas in the city state zip string when writing address on an envelope...

I re-rolled #11 to take out an extra space.

diff between my patch and #11

20c20
<     echo ''. $postal_code .'';
---
>     echo ' '. $postal_code .'';

taking a look at using token as mentioned in #6 might be good in the future

hutch’s picture

Make it print $province_name instead of $province and you fix two bugs in one.

SeanA’s picture

That extra space is needed or there'll be no space preceding the zip code and you'll get:
123 Street Road
Townsville, NY12345

instead of:
123 Street Road
Townsville, NY 12345

yesct’s picture

I dont think so...
with the patch I tested it to get

http://location.yestande.com/node/4

here are more various tests:
http://location.yestande.com/node/16
http://location.yestande.com/node/15
http://location.yestande.com/node/14
http://location.yestande.com/node/13
http://location.yestande.com/node/12
http://location.yestande.com/node/11
http://location.yestande.com/node/10
http://location.yestande.com/node/2
http://location.yestande.com/node/3

If you look at the code, there is a space after the comma after the city:

   if ($city) {
     echo '<span class="locality">'. $city .'</span>';
     if ($province) echo ', ';

and after the end span in the province/state:

   if ($province) {
     echo '<span class="region">'. $province .'</span> ';
SeanA’s picture

You're right... except for the case where we have just the city and zip, with no state/province. As can be seen in your example:
http://location.yestande.com/node/12

yesct’s picture

Oh, totally good catch! How did I miss that!?

that makes the patch in #11 the one to use! (with the "extra" space, which is not really extra after all).

SeanA’s picture

StatusFileSize
new956 bytes

New patch that outputs the full province name instead of the internal code. (see #115323: State/province names should be displayed (during output/views) instead of codes). Otherwise the same as #11.

yesct’s picture

SeanA thanks, but I think putting two issues in one patch makes it hard for the maintainers to commit things, and mark in the changelog what has changed... I think.

Note, the patch to commit is the one in #11

hutch’s picture

There are indeed two separate issues here.

1) Showing province versus province_name. The US folks don't mind the code as it is commonly used but it confounds other countries. Perhaps this should be an option under admin/settings....

2) Commas. A matter of taste really, I personally would like to see the $city_province_postal array removed altogether and the individual fields just printed out with no commas at all. This is a template after all and should just provide a basis for themers to work on.

These are policy decisions IMHO.

yesct’s picture

I agree, there is a need to make it more generic so it can be themed as individual site desire, but I think first, there IS a bug to fix here, with the double comma. Lets get that small fix in, then tackle a more ideal way. :)

hutch’s picture

OK, patch in #11 it is, patches cleanly.

rooby’s picture

Status: Reviewed & tested by the community » Fixed

Committed #11 to D6 and HEAD with a minor coding standards fix of adding braces to the single line if statement.

I also ported and committed to D5.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rooby’s picture

Just realised I committed to the DRUPAL-5 branch instead of the DRUPAL-5--3 branch :(

Committed to DRUPAL-5--3 - http://drupal.org/cvs?commit=372114