Given that the tokens available for use in Pathauto patterns appear to have changed radically, is there any equivalent to the very useful catpath pattern from D6? I don't see anything that looks similar...

The nearest equivalent I can see would be to assemble it by putting together [term:parents:join-path] and [term:name] separated by a slash, but wouldn't that lead to a double slash in the URL if some terms didn't have any parents? Or would Pathauto automatically correct for that?

Comments

fengtan’s picture

Maybe you can use [term:parents:join-path]/[term:name] in D7 where you used [catpath] in D6.
Pathauto trims duplicate separators in pathauto_clean_alias() anyway, so you should not end up with double slashes in the URL.

kenorb’s picture

Issue summary: View changes

The same problem here:
It seem pathauto wrongly converting term:catpath from D6 into term:name in hook_update

function pathauto_update_7005() {
  $replacements = array(
    '[vocabulary:name]' => '[term:vocabulary]',
    '[vocabulary:' => '[term:vocabulary:',
    '[term:catpath]' => '[term:name]',
    '[term:path]' => '[term:name]',

breaking the consistency of old paths.

I've tried [term:parents-all] and [term:parent:parents:join-path], but it seems it doesn't work as expected.

See the comment from token_node.inc:

The 'catpath' (and 'cat') tokens have been removed, as they caused quite a bit of confusion, and the catpath was a relatively expensive query when the taxonomy tree was deep.

It existed only to provide forward-compatability with pathauto module, and for most uses of token.module, it was a relatively useless token -- it exposed a list of term names formatted as a URL/path string. Once pathauto supports tokens, *it* should handle this catpath alias as it's the primary consumer.

kenorb’s picture

By applying drush support for Pathauto at #867578: Add drush commands for bulk alias updating/deleting you may quickly test what could be suitable for you, e.g.:

drush vset pathauto_forum_pattern '[term:vocabulary]/[term:parents-all]'
drush pathauto-aliases-delete Forums
drush pathauto-aliases-generate forum
drush sqlq "SELECT source, alias FROM url_alias WHERE source LIKE 'forum/%'"

Try also:
[term:parent:parents:join-path], [term:vocabulary]/[term:parent:parents:reversed:join-path]/[term:name], but these doesn't work for me, are empty.

kenorb’s picture

Status: Active » Fixed

The best token I've found equivalent to:

[vocab-raw]/[catpath-raw]

is:

[term:vocabulary]/[term:parents-all:3]/[term:parents-all:2]/[term:parents-all:1]/[term:name]
Dave Reid’s picture

Actually [term:parents:all:join-path]/[term:name] is the direct replacement for [catpath-raw].

kenorb’s picture

I'm not sure, because [term:parents:all:join-path]/[term:name] doesn't work for me as a Forum pattern.

[term:vocabulary]/[term:parents:all:join-path]/[term:name]

it generates the aliases like:

forums/mailing-lists
forums/latest-release
forums/bug-reports
forums/modules

and it looks like token is ignored or empty.

When using

[term:vocabulary]/[term:parents-all:3]/[term:parents-all:2]/[term:parents-all:1]/[term:name]

it generates the aliases like:

forums/developers/foo-resources/mailing-lists
forums/pro/latest-release
forums/core/bug-reports
forums/enterprise/modules
Dave Reid’s picture

Ack, sorry that's my fault. The token is actually [term:parents:join-path].

kenorb’s picture

Yes, it works, thank you.

Status: Fixed » Closed (fixed)

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

Summit’s picture

Hi thanks, this helped. I needed:

[term:vocabulary]/[term:parents:join-path]/[term:name]

greetings,
Martijn