-1

I have not found the path field in a view so i have added in my template for views_view_fields.

 <div class="cell small-12 event__link">
     {{ fields.view_node.content }}
 </div>

This provide the path to the content of the default language.

How can i make a twig variable node path multilingual compatible in a view template?

  • 1
    Have you checked the Rendering Language (middle column in the views UI)? Is a content translation available for the item you want to show? – Hudri Jun 5 '18 at 13:06
  • not changing anything when displaying {{ fields.view_node.content }}. – Matoeil Jun 5 '18 at 13:19
  • is there another variable available for the path? – Matoeil Jun 5 '18 at 13:20
  • 1
    Doing this with Twig logic is wrong. Configure your view correctly. See Rendering Language in views admin UI. If using view with fields: add "Link to Content" field. If using view with rendered entity: use normal "{{ url }}" in node template. – Hudri Jun 5 '18 at 14:06
  • 1
    Views does not work this way, such a variable does not exist. Try searching for work-arounds – Hudri Jun 5 '18 at 14:29
0

how simple is that ?

  <div class="cell small-12 event__link">
      <a href="{{ path('entity.node.canonical', {'node': fields.nid.content|striptags|trim}) }}">
        {% trans %}Read more{% endtrans %}
      </a>
   </div>

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.