5

We have a Drupal 8 site with translated content, and using the Pathauto module. The issue we are running into is that when we un-check the "Generate automatic URL alias" on, say, the Chinese node, because the content editors want to customize that URL, that applies to all the other languages of that node, and path aliases are no longer automatically generated.

Ideally, we would like to separately control how to generate path aliases for each language a node is using, whether automatic or custom. The Pathauto_i18n module looks like it might be helpful, but it's woefully unfinished for Drupal 8 and I don't think we have the resources to finish it on our own right now.

Is there something else I am missing?

  • 5
    Yes, that flag is currently per entity and not per translation. That's something that you should report as a feature request for pathauto, it will need to be expanded there. – Berdir May 12 '17 at 21:12
0

I had to create a custom path based on a field. I was able to use hook_pathauto_pattern_alter(). If you need custom path per node then this should work. You will need to add a field. It can be a plain text field. Pathauto conditions. Here is an example of the hook. code review for hook_pathauto_pattern_alter

0

In addition to the post of paulcap1 you can look into pathauto.api.php located inside the pathauto module to see which hook suits you best for setting the path programmatically (if this is an option for you).

The path can be set or modified per language (which is german and english in this case) like this:

\Drupal::service('path.alias_storage')->save("/node/" . $node->id(), '/some_alias/' . $node->id(), "en");
\Drupal::service('path.alias_storage')->save("/node/" . $node->id(), '/some_alias/' . $node->id(), "de");

I hope I did get you right and this is useful to you.

  • You just posted the exact same answer here, drupal.stackexchange.com/questions/169719/…. – Jdrupal May 24 at 7:58
  • You should instead add a comment on the post referring to your answer on the other post instead of answering the same question multiple times, thanks. – Jdrupal May 24 at 7:59
  • Hi, unfortunately I am not yet able to add a comment to posts that are not mine due to low reputation, as I just have started to get active on Drupal-Answers. Sorry for the inconvinience. – Olli Bolli May 24 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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