I'm just getting into using pathauto and I find it pretty powerful. I'm running into an issue that I don't understand though. I've created a hierarchical category set (plant classification) that applies only to one content type (plants) and is required. For every plant added, users should choose the most specific classification that is listed... For example: perrenial -- tomatoes -- red slicer tomatoes. I want these classifications to be automatically reproduced in the url of the nodes that are being created so I put "plant/[catpath]/[title]" in the node path settings for all "Plant" content types. When I do this I recieve the following error:

You are using the token [catpath] which is not valid within the scope of tokens where you are using it.

Why isn't this valid??

I appreciate your help on this! Andrew

Comments

greggles’s picture

Status: Active » Fixed

In that realm you need to use [termpath-raw].

strayhand’s picture

Title: why is token [catpath] not valid for a node path » Trouble with [termpath-raw] spitting out full term path
Status: Fixed » Active

I'm trying to build things in a similar fashion, only [termpath-raw] isn't yielding the aliases that I'm expecting. Instead it's only reporting back the first or top term.

For example I have a content type called "Groups" with a vocabulary assigned to it called "Group." The vocabulary has nested terms as follows:

VOCABULARY:

Group
- Sojourner
-- 2009

PATHAUTO SETTINGS:
In my pathauto settings for "Group" content I have the following settings:

group/[termpath-raw]/[title-raw]

RESULTING ALIAS:
This is what I'm getting from pathauto:

group/sojourner/exploring-egypt-pharaohs-cleopatra

I should be getting...

group/sojourner/2009/exploring-egypt-pharaohs-cleopatra

Does this have something to do with how I've got my taxonomy setup? Does the multiple select throw this off? I was poking around in the code and I could be wrong but isn't the code for the "node" case only reporting back one term? How could it then be spitting out the term path with sub-terms separated by "/" I'm not by any means a PHP genius so please forgive me if I'm totally off here.

Thanks.

CODE: pathauto.module (line 99-114)

        case 'node':
          // We're on a node and it's a book and it has a parent? Get the book path alias
          if (module_exists('book')) {
            if ($object->type == 'book' && $object->parent) {
              $values['bookpathalias'] = drupal_get_path_alias('node/'. $object->parent);
            }
            else {
              $values['bookpathalias'] = '';
            }
          }

          $vid = db_result(db_query_range("SELECT t.vid FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.nid = %d ORDER BY v.weight, t.weight, t.name", $object->nid, 0, 1));
          $category = db_fetch_object(db_query_range("SELECT t.tid, t.name FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.nid = %d ORDER BY weight", $vid, $object->nid, 0, 1));
          $category->vid = $vid;
          // In the realm of nodes these are terms, in the realm of Taxonomy, cats
          $label = 'term';
izallgood’s picture

Version: 5.x-2.3 » 6.x-1.1

I am seeing the same issue with the exception of that for some aliases work.

Example

VOCABULARY:

Games
- Expectant Couples
-- Adventures

PATHAUTO SETTINGS:
In my pathauto settings for "Group" content I have the following settings:

games/[termpath-raw]/[title-raw]

In some cases i get
games/expectant-couples/adventures/sasquatch-adventure
in other cases i get
games/expectant-couples/birds-nest

Both of which contain the taxonomy term adventures

strayhand’s picture

I think I figured out what I was doing wrong. It's not really a bug with the module so much as you have to setup things in a certain way. I had my taxonomy setup so that I could select multiple terms. So for example I was selecting both "Sojourner" and "2009".

What I needed to do was select only the child term, "2009". Now pathauto behaves the way that I intended for it to work and it inserts the full path of the term which includes both "Sojourner" (parent term) and "2009" (child term).

For anyone else trying to figure this out. I would point out that the [termpath-raw] token seems to grab the first term that comes across. SO, don't select multiple terms and everything will work out fine. I hope that helps.

Thanks.

izallgood’s picture

I think that I may be seeing a diffrent problem, being that sometimes i get the correct output and other times i don't.

ennobln’s picture

I have the same problem.
Using Terms with less than 6 letters they will not be shown in the path.

using:

destinations
- europe
-- germany
--- berlin
--- köln

getting this urls
destinations/europe/germany/berlin/[title-raw]
destinations/europe/germany/[title-raw]

using

--- koeln

instead of [köln] getting the same url

using

--- cologne

ist works well. So maybe it is questions of the lenght of the term?

Can somebody help?

dave reid’s picture

Status: Active » Fixed

The original problem has a solution, so marking as fixed.

Status: Fixed » Closed (fixed)

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