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

How to get views header and footer in view block template

0 Answered Questions

Using views field formatter with paragraphs

  • 2018-12-31 10:24:29
  • R. Schleutker
  • 145 View
  • 0 Score
  • 0 Answer
  • Tags:   views paragraphs

2 Answered Questions

[SOLVED] Changing the view mode of EntityReferenceFieldItems programmatically

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
  • 24 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
  • 166 View
  • 0 Score
  • 1 Answer
  • Tags:   8 theming

1 Answered Questions

1 Answered Questions

[SOLVED] Drupal 8 paragraph access in views-view twig file

  • 2018-01-12 07:20:26
  • Aniket
  • 156 View
  • 1 Score
  • 1 Answer
  • Tags:   views 8 paragraphs

1 Answered Questions

cant reach content in block--views

  • 2016-11-17 12:42:16
  • Shao Khan
  • 22 View
  • 1 Score
  • 1 Answer
  • Tags:   views theming

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
  • 806 View
  • 3 Score
  • 1 Answer
  • Tags:   theming 8 blocks

2 Answered Questions

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

Sponsored Content