By Emil Orol


2018-10-09 19:30:16 8 Comments

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 comments

@Emil Orol 2018-10-09 20:36:15

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.

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] How to print fields value in views-view.html.twig in drupal 8

  • 2017-08-02 09:23:52
  • user50292
  • 1931 View
  • 0 Score
  • 1 Answer
  • Tags:   views theming

1 Answered Questions

[SOLVED] Views block doesn't appear on page if only media-type content is selected

  • 2018-10-22 19:49:41
  • ACanadianCoder
  • 32 View
  • 0 Score
  • 1 Answer
  • Tags:   views 8 blocks

1 Answered Questions

[SOLVED] Field template for display mode of referenced paragraph

  • 2018-08-07 22:00:34
  • Max L. Reutlinger
  • 327 View
  • 0 Score
  • 1 Answer
  • Tags:   8 theming

1 Answered Questions

2 Answered Questions

[SOLVED] How to create a custom markup for a views-block?

1 Answered Questions

[SOLVED] how do I add contextual edit links in block template for a block entity?

  • 2016-06-02 22:29:44
  • oknate
  • 1118 View
  • 3 Score
  • 1 Answer
  • Tags:   theming 8 blocks

2 Answered Questions

[SOLVED] Display block based on main content type with view

Sponsored Content