3

The default language of my site is English. Taxonomy terms are translated using Entity Translation. I have created a view that uses aggregation to show Japanese terms (name provided by the Title module).

However, the Japanese terms do not have a path alias, so I need to rewrite the link provided by the view to point to the English term. The URL aliases of the English terms are generated by Pathauto, which strips some words ("to" in "Things I like to do").

Example:

  • English term: Listening to Music
  • Pathauto alias: listening-music
  • Japanese term: 音楽鑑賞
  • Desired output: 音楽鑑賞 (link pointing to listening-music)

I tried rewriting the link to [name] (the English term) with conversion to lowercase and spaces converted to dashes, but this causes the link to be listening-to-music, not listening-music. Ideally, I would like to keep pathauto settings as they are and somehow grab the URL of the term within views. Is this possible?

2 Answers 2

4

To get path of taxonomy term in default language (in your case it is English) you can use url() function, example:

$term_url = url('taxonomy/term/'. $term->tid, array('language' => language_default()));
0

I solved this by removing all the prepositions from the "Words to exclude from paths" on the Pathauto configuration page and then deleting and bulk updating all taxonomy aliases. For those aliases with () or other symbols in their names, I manually added redirects using the Redirect module. Not pretty but it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.