Create hierarchical taxonomy url alias with token term:parents using a field other than term:name Sorry, the title is a bit of a mouthful but I will attempt to clarify.

I have a question about pathauto tokens to create a URL alias for a nested/hierarchical taxonomy. 

Specifically, I have a taxonomy called Category, which is n layers deep; e.g:


  Category level 01 > Category level 02 > Category level 03 


And so on. The question appears to have been asked many times before and there are a number of good solutions, including the following pattern:


  [term:parents:join:/]/[term:name]


This yields the following url alias for the above example:


  category-level-01/category-level-02/category-level-03


Pretty straightforward. This would be perfect except in my example the taxonomy terms are in Chinese.

I need English in the path aliases, so I have set up a new field in my taxonomy called 'Name English'. This gives me the following replacement pattern:


  [term:parents:join:/]/[term:field_name_english]


Which is almost perfect, but the parents default to using the name field, and there does not seem to be an easy way of overriding this. I cannot use the parent taxonomy terms with delta because it's not dynamic; e.g:


  [term:parents-all:1:field_name_english]/[term:field_name_english]


Some taxonomy depths will be deeper than others.



So, in summary, I need to somehow specify an alternate term field to name for the [term:parents] token. To do this I assume I will need to do one of the following:


Create a custom token
Override the current [term:parents] token


Can anyone advise on this? Thanks a million.
Option 1

You could copy the token created by the taxonomy module for [term:parents:join:/] and recreate it in your own module, using your field as a substitute for title. 

This would require some familiarity with the token system. There is also a module entitled 'Custom Token' that might be worth a look, though I have not used it.

Option 2

One divergent way I could suggest to get around this is to use drupal's title field to store your english language title, and another field to store the chinese title (*field_chinese_title*).

You could then preprocess the node title within your theme/module to replace $variables['title'] with *field_chinese_title*. You might also have to do this for menu entries and search results, and you would also have to remember to use *field_chinese_title* for views fields etc.

YOURTHEME/template.php:

&lt;?php
function YOURTHEME_process_page(&amp;$variables) {
  if (isset($variables['node']-&gt;field_chinese_title['und'][0]['value'])) {
    $variables['title'] = $variables['node']-&gt;field_chinese_title['und'][0]['value'];
  }
}

function YOURTHEME_preprocess_search_result(&amp;$variables) {
  // use chinese version of title for search results
  if (isset($variables['result']['node']-&gt;field_chinese_title)) {
    $variables['title'] = $variables['result']['node']-&gt;field_chinese_title['und'][0]['value']);
  }
}


I admit I have little experience of multi language sites, and I do realise that this method might look a little crude, but I have used a variation (with autonodetitle) to differentiate the titles used by menu entries and nodes (so that menu entries can optionally be more concise) and it works beautifully. For my use case, I later found a module for that...