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

CommentFileSizeAuthor
#1 location_tokens.patch2.13 KBgreggles

Comments

greggles’s picture

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 » feature
Status: Active » Needs review
StatusFileSize
new2.13 KB

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.

khoogheem’s picture

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]

Zoologico’s picture

Tracking.

robloach’s picture

Status: Needs review » Closed (duplicate)
harry slaughter’s picture

There's a bug in greggles patch.

The line:

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

should read:

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