I'm not sure if this is the problem with the location module or the views, but it looks like Province title gets missed every time I put an argument there.

For example: In the default Location View there are 3 arguments. When I define titles for them as %1, %2, %3 respectively - the United States and the City Names show up as titles and breadcrumbs just fine, but State titles and breadcrumbs are blank.

Any ideas on how to fix that?

Thank you!

CommentFileSizeAuthor
#8 location_country_province_empty.jpg12.46 KBsummit

Comments

jordanlewin’s picture

I have this same issue, and nothing really to contribute here (yet) except that I can confirm it's an issue across more than just one install.

jordanlewin’s picture

I've done a little messing around in location_view.module to see if I can fix this, and here's a fix I've found. It seems that when multiple countries are not allowed (i.e. the site is set to one country by default) that the proper variable $country isn't being spit out in this snippet below, which is on line 784:

  case 'title':
    return empty($query) ? LOCATION_VIEWS_UNKNOWN : $provinces[$country.'-'.$query];

I've added a line here to check whether $country is set, as it's being used to get the proper province name for the argument, and if it's not, to set it to the site's default country:

  case 'title':
    if (!$country) { $country = variable_get('location_default_country', 'us'); }
    return empty($query) ? LOCATION_VIEWS_UNKNOWN : $provinces[$country.'-'.$query];

This seems to be working on my site, which only has Canada as the country allowed, I haven't tested this on a site with multiple countries allowed. I assume this would still work there because even with multiple countries allowed there is still a default country that would get set here. If you want to specify a country's province here other than one in the default country, I assume it would need to be passed as another argument in the view, and then $country would already be set and it wouldn't be set here to the variable 'location_default_country'.

jordanlewin’s picture

Sorry, this was all in location_views.module, not location_view.module.

jordanlewin’s picture

One more note to add to this is that the arguments are case sensitive here (need to be uppercase), so if the province code argument is being input as lowercase in the URL, they need to be changed to uppercase for the view argument to work properly. I achieved this by inserting this piece of code into the "Argument Code" text box in the View UI:

// Make the argument uppercase
if ($args[0]) {
  $args[0] = strtoupper($args[0]);
}
return $args;

It could also be done in the module itself which would probably be better by using this code:

case 'title':
  if (!$country) { $country = variable_get('location_default_country', 'us'); }
  return empty($query) ? LOCATION_VIEWS_UNKNOWN : $provinces[$country.'-'.strtoupper($query)];
gemini’s picture

Thanks for your help jordanlewin! I'll try your fix tonight.

gemini’s picture

It works! Thank you very much!

bdragon’s picture

Status: Active » Closed (fixed)
summit’s picture

StatusFileSize
new12.46 KB

Hi,

Original issue still occurs on D6 latest .dev.
Also the view-fields country and province are not shown.

See attached picture for example.
This is a views output in views2 with location view and using the country france as argument, so the country france should be filled in within the views-field.
Country and province field are not shown, city field IS shown.

Thanks a lot in advance for going into this again!

Greetings,
Martijn
www.aanbiedingen-herfstvakantie.nl

summit’s picture

Version: 5.x-1.x-dev » 6.x-3.x-dev
Status: Closed (fixed) » Active

Sorry, because of drupal-error, status not correct. Set it back to active because on D6 latest 3.dev same issue occurs.

Greetings,
Martijn

yesct’s picture

could someone please create a patch ( http://drupal.org/patch/create ) against the most recent dev version? This will make it easier for more people to test the fix, and also for it to get committed. Thanks.

msypes’s picture

Joining in the fray:

I'm not finding that disallowing multiple countries is an issue. I'm getting something very like the original situation described by gemini. I have a "drill down" view of locations using %1 as country, two pages specifically for the US & Canada with a second argument for the state/province, and a third page for other countries which don't routinely use a province as part of the address.
My initial page provides a proper list of countries, and the US page a list of states. The "non-province" countries also function just fine. However, Canada's page displays a "broken" list of provinces: None of the province names are presented. I have Views set to display the number of records for each, and that shows up fine.

Assuming that didn't make any sense ;-) I should get something along the lines of:
Alberta (6)
British Columbia (2)
etc.

Instead I get
(6)
(2)
etc.

It seems as though Location isn't properly pulling out the province name from the array in location.ca.inc

Michael

yesct’s picture

Status: Active » Postponed (maintainer needs more info)

lots of work went into the new official release, Please check to see if this is still a problem in the new release. If it is, reply with a new summary and set the status back to active.

Standard Machine’s picture

Status: Postponed (maintainer needs more info) » Active

I believe that this is still an issue with the 3.1 version, I tried switching to the latest dev as well, but it didn't fix it.

I have the same problem as #11. The province names are blank when used as arguments that are supposed to printed in views.

This is true for page titles as well as the Views arguments summary output.

It is somehow related to the default country. /admin/settings/location/main

When I set it to the US, US states work; but Canadian provinces don't. When I set it to Canada, Canadian provinces work but then the US states don't. When I don't set a default country neither arguments work.

Is there some additional configuration needed for multiple countries to work with views arguments?

xpersonas’s picture

I'm having the same issue as #13

Slacky08’s picture

Same issue here... adding a location field to a view won't show the province name, but adding the Location: Province will show the location code (not name).

I also use contemplate to theme my content nodes and I can access all the data (e.g. province name) fine, and I know the info on province is still in the database (can see it in phpMyAdmin), but it seems not to work when using the Location views field.

Any idea's how to fix this?

mrjeeves’s picture

Same issue on 3.1 here. looking into the code, i'm finding that the argument handler is not properly populating the $country which results in no name, even though the data "appears" to be there (based on the proper numeric output in the summary)

skulegirl’s picture

Issue summary: View changes

I had this problem too but finally figured it out... make sure that your country argument precedes your province argument. E.G., (%2, %1) => (province, country).

legolasbo’s picture

Status: Active » Closed (outdated)

Closing old D6 issues as D6 is end of life