<p>Can't you fetch all the blocks with <code>block.topicTeaserItems.all()</code></p>

<pre><code>{% include 'modules/module-squareteaser/_module-squareteaser' with {
  squareTeasers: block.topicTeaserItems.all()
} %}
</code></pre>

<p>And then you display the headlines with <code>item.entryTopicHeadline</code></p>

<pre><code>&lt;div class="squareteaser__wrapper _parent-3-child"&gt;
  {% for item in squareTeasers %}
    {% include 'modules/module-squareteaser/_module-squareteaser-item' with {
      headline: item.entryTopicHeadline
    } %}
  {% endfor %}
&lt;/div&gt;
</code></pre>

<p>A simplified version would look like</p>

<pre><code>&lt;div class="squareteaser__wrapper _parent-3-child"&gt;
    {% for item in block.topicTeaserItems.all() %}
        {{ item.entryTopicHeadline }}
    {% endfor %}
&lt;/div&gt;
</code></pre>

CC BY-SA 4.0
2018-05-03T14:30:31.370Z
Sure i could do it with "item.entryTopicHeadline". But i am using the "_module-squareteaser.twig" for multiple includes at different places on the website. So thats why i wanna go with just "squareteaserHeadline", Thought its somehow possible.
Mvrcel Boer
CC BY-SA 4.0
2018-05-03T14:33:55.947Z
You would have to create a new array of headlines by looping through all blocks in your `_overview-topicTeaser.twig`
Robin Schambach
CC BY-SA 4.0
2018-05-03T15:03:32.090Z
And how i do this? :)
Mvrcel Boer
CC BY-SA 4.0
2018-05-03T15:05:25.387Z
This would be a new question, but there are plenty examples how to create an array in twig. https://twig.symfony.com/doc/2.x/filters/merge.html
Robin Schambach
CC BY-SA 4.0
2018-05-03T13:47:47.140Z
2018-05-03T14:13:06.397Z
2018-05-03T14:13:06.397Z
Robin Schambach
<p>So my 1. file is &quot;_overview-topicTeaser.twig&quot; which is within a matrix:</p>
<pre><code>{% include 'modules/module-squareteaser/_module-squareteaser' with {
  squareTeasers: block.topicTeaserItems.all(),
  squareteaserHeadline: block.topicTeaserItems.one().entryTopicHeadline
} %}
</code></pre>
<p>And my 2. file is &quot;_module-squareteaser.twig&quot;:</p>
<blockquote>

<pre><code>    &lt;div class=&quot;squareteaser__wrapper _parent-3-child&quot;&gt;
      {% for item in squareTeasers %}

        {% include 'modules/module-squareteaser/_module-squareteaser-item' with {
          headline: squareteaserHeadline
        } %}

      {% endfor %}
    &lt;/div&gt;
</code></pre>
</blockquote>
<p>So i am looping in the 2. file the file &quot;_module-squareteaser-item.twg&quot; and want to put out the &quot;squareteaserHeadline&quot; in the frontend. But it always gives me the same headline from my first teaser in the loop, makes sense to me cause i am using the &quot;one()&quot; when i include the variable &quot;squareteaserHeadline&quot; in the first file.  But if i delete the &quot;one()&quot; i get nothing... so how do i get all teasers whith their own headline?</p>
<p><a href="https://i.sstatic.net/969BO.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/969BO.png" alt="enter image description here" /></a></p>

<craft3><loop><include><plugin-supertable>
Get the variables of a loop from an include file
# Get the variables of a loop from an include file

(Asked by: username_0 on 2018-05-03)

So my 1. file is "_overview-topicTeaser.twig" which is within a matrix:
{% include 'modules/module-squareteaser/_module-squareteaser' with {
  squareTeasers: block.topicTeaserItems.all(),
  squareteaserHeadline: block.topicTeaserItems.one().entryTopicHeadline
} %}

And my 2. file is "_module-squareteaser.twig":

    
      {% for item in squareTeasers %}

        {% include 'modules/module-squareteaser/_module-squareteaser-item' with {
          headline: squareteaserHeadline
        } %}

      {% endfor %}
    


So i am looping in the 2. file the file "_module-squareteaser-item.twg" and want to put out the "squareteaserHeadline" in the frontend. But it always gives me the same headline from my first teaser in the loop, makes sense to me cause i am using the "one()" when i include the variable "squareteaserHeadline" in the first file.  But if i delete the "one()" i get nothing... so how do i get all teasers whith their own headline?

**Tags:** craft3, loop, include, plugin-supertable


---

## 1 answers

### Answer by username_1 on 2018-05-03. Score: 1

Can't you fetch all the blocks with block.topicTeaserItems.all()
{% include 'modules/module-squareteaser/_module-squareteaser' with {
  squareTeasers: block.topicTeaserItems.all()
} %}

And then you display the headlines with item.entryTopicHeadline

  {% for item in squareTeasers %}
    {% include 'modules/module-squareteaser/_module-squareteaser-item' with {
      headline: item.entryTopicHeadline
    } %}
  {% endfor %}


A simplified version would look like

    {% for item in block.topicTeaserItems.all() %}
        {{ item.entryTopicHeadline }}
    {% endfor %}

> **Comments:**
> **username_0**: Sure i could do it with "item.entryTopicHeadline". But i am using the "_module-squareteaser.twig" for multiple includes at different places on the website. So thats why i wanna go with just "squareteaserHeadline", Thought its somehow possible.  
> **username_1**: You would have to create a new array of headlines by looping through all blocks in your `_overview-topicTeaser.twig`  
> **username_0**: And how i do this? :)  
> **username_1**: This would be a new question, but there are plenty examples how to create an array in twig. https://twig.symfony.com/doc/2.x/filters/merge.html  

---

