0

I was referring to this documentation, but am unsure if what I'm trying to do is possible: https://www.drupal.org/docs/8/theming/twig/functions-in-twig-templates#path

In the section, it refers to this on building a URL:

{# Link to node page. #}
<a href="{{ path('entity.node.canonical', {'node': node.id}) }}">{{ 'View node page'|t }}</a>

This returns a TRULY relative URL, in the sense that if I'm on an English node, the URL is translated to english. If on a Spanish page, the URL is translated. The thing is, I'm trying to create a link in the nodes to the OTHER language, so I need to be able to create unique links for each language in the opposing language's TWIG.

Anyone know of a way to get this URL in a language-dependant manner?

3
  • 1
    This might help. stackoverflow.com/a/45232856/295112
    – Kevin
    Commented Apr 6, 2018 at 15:47
  • Pardon my ignorance, Kevin, but would the PHP code on that article require me to put it in a preprocess function, and print that out in the chosen twig template? Or is there a way with TWIG to do a similar ting? Sorry, I'm new to Drupal 8 theming.
    – DJ Monzyk
    Commented Apr 6, 2018 at 16:00
  • Potentially... drupal.stackexchange.com/questions/217009/…
    – Kevin
    Commented Apr 6, 2018 at 16:04

0

Your Answer

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

Browse other questions tagged or ask your own question.