1

I created a view of paragraphs and I passed the parent ID as the contextual filter using a relationship to the content that use the field that reference the paragraph.

I can see the data been display and now I want to theme the output that I want to display on a block. I created a custom template file for the view block:

block--views-block--MY-VIEW-NAME-block-1.html.twig

and it is working. I can see the content of the view by adding:

{% block content %}
{{ content }}
{% endblock %}

But I would like to access the fields value individually. I have try the followings without luck:

content.field_name
content.field_name[0]
content.field_name[0].value

What am I missing?

1

I finally found the answer to this issue. Here it is in case some one is having the same issue.

The solution is insanely simple use the views fields template.

In my case I created a new template:

views-view-fields--VIEW-NAME.html.twig

And now you can access your fields values like this:

{{ fields.field_NAME.content }}

More details here

Enjoy.

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.