adding token hooks for location

khoogheem - September 5, 2007 - 21:43
Project:Location
Version:6.x-3.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

I have created a pathnode_auto_location.inc file with:

function pathauto_node_location_token_list($type = 'all') {
  if ($type == 'node' || $type == 'all') {
    $tokens['node']['countrycode']   = t("Two Letter Country Code.");
    $tokens['node']['countryname']   = t("English country name.");
    return $tokens;
  }
}

/*
* Implementation of hook_token_values()
*/

function pathauto_node_location_token_values($type, $object = NULL) {
  if ($type == 'node') {
    $countries = _location_get_iso3166_list();
    $tokens['countrycode']    = $location['country'];
    $tokens['countryname']    = pathauto_cleanstring($countries[$location['country']]);
    return $tokens;
  }
}

However nothing shows up. I have some nodes with country location stored and want to get pathauto to generate urls that would be such http://www.example.com/netherlands/blah such that when multiple titles might have the same name it will be easy to tell that it is assigned to that country.

what am I missing?

thanks for the help

#1

greggles - September 13, 2007 - 15:07
Title:adding .inc files for location» adding token hooks for location
Project:Pathauto» Location
Version:5.x-2.0-beta2» 6.x-3.x-dev
Category:support request» feature request
Status:active» needs review

Here are some token hooks for location module. This will enable use of Location with modules like pathauto, auto node title, custom breadcrumbs, etc. Seems really handy to me. If one or two other people could test them to make sure it works then I think we can commit it.

AttachmentSize
location_tokens.patch 2.13 KB

#2

khoogheem - September 14, 2007 - 03:29

Thanks..

They show up in pathauto as an option but when I put them into my video nodes
[countryname]/[title]

I still only get [title]
I tried even putting it into the catchall and that still only sets it to [title]

#3

Zoologico - November 27, 2007 - 17:37

Tracking.

#4

Rob Loach - January 28, 2008 - 16:58
Status:needs review» duplicate

http://drupal.org/node/165678

#5

Harry Slaughter - February 6, 2008 - 21:14

There's a bug in greggles patch.

The line:

if (isset($node->location)) {

should read:

if (isset($object->location)) {

 
 

Drupal is a registered trademark of Dries Buytaert.