I have a view that has a dynamic path and I want to create a path alias for each language installed on my site. Following the answer on How do I translate view's page path alias? I'm able to create a path alias when no dynamic path is involved in the view, but when a contextual filter with dynamic path is in the view I can't find how to create the path alias.

The view is a simple view like this:

enter image description here

So, how do I translate view's page path alias that has a dynamic path like /jobs/% ?

  • @NoSssweat How do you think that I should create the alias? /jobs/% ? – Adrian Cid Almaguer Apr 18 '18 at 20:51
  • I guess, worth a try. – No Sssweat Apr 18 '18 at 20:52
  • @NoSssweat is not working, can you try on your side to see if is something here in my environment? – Adrian Cid Almaguer Apr 18 '18 at 20:59
  • Didn't work, I got Either the path '/taxonomy/term/%' is invalid or you do not have access to it. – No Sssweat Apr 18 '18 at 21:03

Views pages generate routes including route parameters for contextual filters. So you could add for each language a duplicate page, set a language specific path and inherit all other properties from the master display.

But as the routing system is not language specific this has some shortcomings. You get multiple language prefix/route path combination, which is not good for SEO and makes it difficult to build outgoing links.

Language specific path handling is outside of the routing system. The standard tool for this is path aliasing, so you would need to set for each dynamic value and language combination an alias in the lookup table. Don't know if you can generate them with Pathauto, but I wouldn't recommend it anyway in this case, because the path has a clear pattern you can easily transform in a custom path processor to match the internal view's page display route.

| improve this answer | |
  • Thanks for your answer, is not possible with pathauto, or at least I can't find how to do it. I was thinking in generate with some custom code an alias for each possible combination. It seems to be one way, and I'm trying to do something similar to path_alias_xt tagging a service with path_processor_outbound and it seems to work, I'm doing tests now. Do you think that using a service tagged with path_processor_outbound will works fine? – Adrian Cid Almaguer Apr 19 '18 at 21:02
  • 1
    Yes, exactly, you need tagged services. A path processor usually contains two, inbound and outbound. More important to start with would be inbound to get the translated path working you enter in the browser. – 4k4 Apr 19 '18 at 21:37

The Extended Path Aliases module, should be what you are looking for, it is only available as a dev version, but it is worth a try :)

| improve this answer | |
  • How do you think that I must configure the module to solve the problem? – Adrian Cid Almaguer Apr 19 '18 at 15:23
  • Actually I don't know this module very well but I would just try to see if anything on the configurations page makes sense to configure. – user72672 Apr 19 '18 at 16:58
  • I tried with different configs, but without luck. – Adrian Cid Almaguer Apr 19 '18 at 18:34
  • I tried this module and added some patch, then created some URL alias like this /job/% => /trabajo/% . I didn't work – Carlos Jun 6 '18 at 14:56

For the moment the only solution that is working for our team is implementing the Inbound and Outbound Processor plugins to allow you to interfere with the process of processing incoming and outgoing URLs.

You can check an example in the PathProcessorAlias page and there is a good article in Russian named Drupal 8: Inbound and Outbound Processor (The automatic translation of Google Chrome is working fine for this article)

Another good article talking about how this works is How to hide Order ID from commerce checkout process in Drupal 8

| improve this answer | |

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.