Hi,

In List, Table, and Map views of location data are country names SUPPOSED to be abbreviated? That's what's happening to me...

http://www.justcoffee.net/growers
http://www.justcoffee.net/mapofgrowers

I would prefer "id" to read as "Indonesia" and "et" to read as "Ethiopia".

Thanks!

Kevin

Comments

KarenS’s picture

Project: Location » Location Views
Version: 4.7.x-1.x-dev »

I'm moving this to the location views issues list, since it looks like a views issue. I can't speak for the GMap module (you'll have to ask your question on that list) but yes, you should see the full country name in views.

First, make sure you have the latest version of the location views module and the location module (both 4.7 based on the version you selected above). Then make sure to clear the cache. You can do that by going to the admin/modules page and just saving it. Next go to views, pull your view up and just save it again.

Then see if your view is working (i.e. it might be a caching problem that will be cleared up by all these steps). If you still have a problem after that, export the view you are using and paste it in this thread so I can see what's in it.

kevinwalsh’s picture

Thanks Karen! No luck though... I re-installed the newest location module just to be sure (location module now contains the location_views module, right?) and re-saved both the admin/modules page and the view in question. So here's the exported view for your perusal.

  $view = new stdClass();
  $view->name = 'Growers_cooperatives';
  $view->description = '';
  $view->access = array (
  0 => '1',
  1 => '2',
  2 => '3',
  3 => '7',
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = 'Growers Cooperatives list';
  $view->page_header = '<p><img src=\"/files/active/1/230_small.jpg\" alt=\"\" /><br /></p><p>The people who make our business possible...</p><p>(in this case members of Asociacion Civil Maya Productores Santa Anita and Manos Campesinas in Guatemala) </p>\r\n\r\nYou can see a full map of our growers\' cooperatives <a href=\"/mapofgrowers\">here</a>.\r\n\r\nMore to come soon...\r\n';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'table';
  $view->url = 'growers';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '99';
  $view->sort = array (
    array (
      'tablename' => 'location',
      'field' => 'country',
      'sortorder' => 'ASC',
      'options' => '',
    ),
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => '',
      'handler' => 'views_handler_field_nodelink',
    ),
    array (
      'tablename' => 'location',
      'field' => 'city',
      'label' => '',
    ),
    array (
      'tablename' => 'location',
      'field' => 'province',
      'label' => '',
    ),
    array (
      'tablename' => 'location',
      'field' => 'country',
      'label' => '',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'content_growers',
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(location, node);
  $views[$view->name] = $view;
KarenS’s picture

Status: Active » Fixed

I found the problem and committed a fix to the 4.7 version. As noted in another thread, be sure to get the latest version of the location module, too, since there is a change to a function name.

KarenS’s picture

Also committed fix to cvs.

kevinwalsh’s picture

many thanks Karen!

kevinwalsh’s picture

Whoops, i'm confused... stupid question probably...

http://drupal.org/project/location lists the most recent cvs as 8/24/2006 and
http://drupal.org/project/location_views says that it's embedded in the location module.

Which module did you commit the fix to?

kevinwalsh’s picture

ok, i think i almost figured it out.... i replaced the location_views.module file in my location > contrib folder
with this:
http://cvs.drupal.org/viewcvs/*checkout*/drupal/contributions/modules/lo...
The location.module file in the cvs is a week old, so i didn't update that.

The countries now appear correctly on any views (Ethopia instead of et, East Timor instead o f LT, etc.), and the province appear correctly on gmap views. However the provinces are causing an error on table views.

The PHP error is as follows:

Fatal error: Call to undefined function: location_province_select_options() in /home/jcoffee/public_html/modules/location/contrib/location_views/location_views.module on line 641

which reads as

/**
 *  Format a province name
 */
function location_views_province_handler($fieldinfo, $fielddata, $value, $data)  {
   $array = location_province_select_options();
   $provinces = $array['#options'];
   $location['province'] = $data->location_province;
   $location['country']  = $data->location_country;
   $values = location_api2form($location);
   return $provinces[$values['province']];
}
kevinwalsh’s picture

Status: Fixed » Active

I just tested the province field in node/xxxx/edit for a location-enabled node type and the data i inserted didn't "stick".

kevinwalsh’s picture

Ditto for adding a new node with a province field.

KarenS’s picture

Status: Active » Fixed

The problem on the unnamed function is because you need the latest version of the location.inc. (I said you needed the latest version of location.module, but it is location.inc that you need.) You can get it from the cvs repository (http://cvs.drupal.org/viewcvs/drupal/contributions/modules/location/).

The problem about saving locations is noted in http://drupal.org/node/79015. That's a different problem than the one this issue was opened for, so you might want to check that thread out.

kevinwalsh’s picture

OK, thanks for your help on this Karen!

kevinwalsh’s picture

Okay, here's a weird one. The provinces only display in my Views Tables if the Country is also displayed. Not a big deal, but i thought that this might be of interest...

BTW, is this the right protocol for posting issues?

KarenS’s picture

Status: Fixed » Active

Yes, this is the right way to post issues, and yes this is a weird one. I don't have time to investigate it right away, so I'll mark it active and get back to it.

Thanks!

wrunt’s picture

Title: Unwanted country abbreviations in List, Table, and Map views of location data » Location province doesn't show in views unless location country is also used.
Category: support » bug
Status: Active » Needs review

I had the same problem as Kevin. The problem is in location_views_province_handler. If you don't have the country shown in the view then $location['country'] isn't set, so the call to location_api2form doesn't return anything.

I don't know if there's a better fix, but what I've done is changed this line (line 674):

$location['country'] = $data->location_country;

To this:

$location['country'] = isset($data->location_country) ? $data->location_country : variable_get('location_default_country');

This way if your view doesn't contain the country as a field then the default country is assumed.

locomo’s picture

Hi

I think my problem is related to this post. I've got a view that sorts a number of schools by state. The state/province currently displays abbreviations:

AK
AL
AR, etc and I'd like to view the entire name:

Alaska
Alabama, etc - is this possible. I'd also like to use the full state/province name in the Title but %1 in the Title field of my argument also gives me the abbreviation.

Any thoughts? Thanks!

KarenS’s picture

Status: Needs review » Fixed

I've made a number of recent commits and this problem should (finally!) be fixed. Sorry for taking so long to get it done.

locomo’s picture

hey Thanks Karen! That definitely solved a few things. But I'm still having a little trouble getting the behavior I'd like.

I starting tracking down a couple of issues but am not really sure how everything works here.

In location_views.module around line 823, I don't think the title is working for some reason - $country doesn't seem to be populated. I replaced this line
return empty($query) ? LOCATION_VIEWS_UNKNOWN : $provinces[$country .'-'. $query];
with
return $provinces['us-' . $query];

and was able to hack the title that I wanted.

also, the provinces are now being presented with their full name in the summary view but i also wanted those fullnames as the argument in the URL (ie http://domain.com/schools/alaska and not http://domain.com/schools/AK)

i can get the links to show up the way I want by replacing line 817 with:
return l($query->province == LOCATION_VIEWS_UNKNOWN ? LOCATION_VIEWS_UNKNOWN : $provinces[$query->country .'-'. $query->province], "$arg/" . $provinces[$query->country .'-'. $query->province]);

but once you click on that link the view breaks down and shows no results (because I think its expecting the province in the abbreviated form). This is where I got stuck.

any help would be most appreciated!!

morgan

Anonymous’s picture

Status: Fixed » Closed (fixed)
Chad_Dupuis’s picture

This is still an issue in the 2.x dev branch of Location. Other fixes such as - http://drupal.org/node/170062 work fine so long as you are only working within one country and it is the default.

As others have posted out - the country variable is not getting through to location_views_handler_arg_province . The only function is a little strange, not least of which because country isn't set.

I think the only reason the link section works (and why the name isn't spelled out) is that the variable is carrying through the state name (i.e. MA), but the lookup fails (i.e. Massachusetts) because it wasn't us-MA = Massachusetts, but it only has MA so that is what goes through to the url.

I've been trying to re-work this function but it is always hard to take someone elses work and fix it. Anyone with more experience in the module might have a better chance at this.

The country variable is set correctly at location_views_handler_arg_province but the array that is returned never makes it through to any of the other functions.

Any help in getting this to work correctly would be appreciated.

-Chad.

Chad_Dupuis’s picture

Component: Miscellaneous » Code
Priority: Normal » Critical
Status: Closed (fixed) » Active
Chad_Dupuis’s picture

Just wanted to point out that this is still an issue in the 5.x....test 3 version of location.

I get:
Home › › Country › State

When viewing a page in Chattanooga, TN, USA

Instead of:

Home > United States > Tennessee