1

I am new to Drupal8. How can i get the content ? I call a view in page.html.twig like:

{{ page.content.views_block__serviceboxen_block_1 }}

and created a template with name:

block--views-block--serviceboxen-block-1.html.twig

How can i access to the content from my view in this template ? I have no idea when i use

{% for row in rows %}

and

{% for item in items %}

thanks a lot.

0

solution: you can access the fields with 'content'

e.g. content.body or content.your_field_name.value

in a iteration it looks like:

<ul>
  {% for item in content['#view'].result %}
      {% set topic = item._entity %} {# just for shorter writing #}

       <li>{{ topic.title.value }}</li> {# or topic.yourFieldName.value #}

  {% endfor %}
</ul>

Hope it'll help

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.