I've setup tokens for the location data. Since I can't upload two files in one issue, I'll upload the new file that needs to be added to the location module directory in this post. The post below has the patch for the location module that calls the location tokens if the token module exists.

To use the attached file you need to change the extension from .txt to .inc

-Tom Friedhof

Comments

tom friedhof’s picture

StatusFileSize
new1.04 KB

Here is the patch for location module to call the file attached above.

The extension for the file above needs to be changed from .txt to .inc to work.

gemini’s picture

Uploaded the inc file and patched the location.module - can't get it to work. Generated URLs display token names.

robloach’s picture

Priority: Normal » Critical
StatusFileSize
new3.37 KB

Modified version of your location_token.inc to use a new naming system (location- prefix), as well as the addition of [location-provincename_N] and [location-countryname_N]. [location-provincename_N] outputs the location's English province/state name (Ontario), and [location-countryname_N] outputs the location's English country name (Canada).

Of course, you'll have to rename location_token_2.txt to location_token.inc.

robloach’s picture

Version: 5.x-1.x-dev » 6.x-3.x-dev
StatusFileSize
new3.44 KB

Fixed for checking if there is a Location field active on the content type.

jacine’s picture

subscribing :)

xerbutter’s picture

Thanks for the token module integration. It works great, except that for me [location-province_N] shows up as us-MA (for Massachusetts, for instance) and [location-provincename_N] does not work at all (because it's being fed "us-MA", but expecting just "MA" I think).

Any thoughts?

Thanks for your help.

xerbutter’s picture

Just wanted to add that print $node->locations[0]['province'] prints out "MA", so I'm not sure where the us- is getting added.

Zoologico’s picture

Tracking.
Drupal and the people associated with it just rock.
Thanks.

Zoologico’s picture

What are the steps to get this working?

1) Download HEAD version of location?
2) Add location_token.inc to location folder
3) Add token_support.inc to token folder
4) Enable/update modules

Should this work after these steps?

robloach’s picture

Assigned: tom friedhof » Unassigned
Status: Reviewed & tested by the community » Needs work

Greggles submitted a patch, which will have to be merged with the current patch (addition of check_plain).

bshensky’s picture

Also tracking. Great for using with auto-title, once we can all get it to work... Go Greggles Go!

jody lynn’s picture

Status: Needs work » Needs review
StatusFileSize
new3.98 KB

I added check_plain around all the token values and got rid of the location_tokens.inc approach so that this is now just one patch for location.module. So far it's working for me.

(For other fools like me, you have to be updated to pathauto 5.2 to even be using tokens!)

robloach’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

bdragon’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD, thanks all!

ellanylea’s picture

I applied the patch in Comment #12 above (ie added the lines that start with + to location.module), but I get the token names [location-city_N] [location-country_N] and not Montreal, Canada.

I'm using the latest: Drupal 5.7, Pathauto 5.x-2.1, Token 5.x-1.10, Location 5.x-1.x-dev (which is the 5.x-2.x branch as of 2007-Oct-31).

I know work is going into Location 3, and love the Drupal community for it! For now, does anyone know how to get token integration to work on a live site with 5.x-1.x-dev?

Thanks so much!

ellanylea’s picture

Answered my own question, in case it could help others: the problem was not in patching, but in my implementation.

I'm using autonodetitle, so I usually just copy & paste the "Replacement patterns". The location Replacement pattern looks like [location-country_N] and says "If there are multiple locations per node, N is the iteration, starting with 0".

Since I only have one location per node, I assumed the default Replacement pattern would work... but it didn't. Once I used [location-country_0], everything was peachy!

Thanks Tom, Lynn, Rob for the patch, consolidating the patch, and the commit :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

elvis2’s picture

Thank you for pointing this out. I too am using auto node title module, and could not get location names when using [location-name_N] as the token. But using [location-name_0] did work.

Thanks!

kruser’s picture

I'm getting empty values when using cck_location. Any of the following produce empty node_autotitle values...
[field_cck_location-name] Location name
[field_cck_location-street] Street location
[field_cck_location-additional] Additional
[field_cck_location-city] City
[field_cck_location-province] State/Province
[field_cck_location-postal_code] Postal code
[field_cck_location-country] Country
[field_cck_location-fax] Fax number
[field_cck_location-phone] Phone number
[field_cck_location-province_name] Province name
[field_cck_location-country_name] Country name
[field_cck_location-map_link] Map link
[field_cck_location-coords] Coordinates