<p>Oli, thanks for pointing me in the right direction. Your answer was close, but there's a slight modification:</p>
<pre><code>{% set blocks = entry.nutritionBuilder %}

{% set item = clone(blocks).type('blockCalories').one() %}
{{ item.nutrionValue }}

{% for block in clone(blocks).level(1).all() %}
...
{% endfor %}
</code></pre>
<p>The cloning needs to happen when setting the <code>item</code> variable as well as in the for loop.</p>

CC BY-SA 4.0
2020-10-16T04:57:39.273Z
Ha, too quick :) I've corrected the answer.
Oli
CC BY-SA 4.0
2020-10-15T13:49:25.663Z
2020-10-15T13:49:25.663Z
Vaughn D. Taylor
<p>This is because of <a href="https://craftcms.com/docs/3.x/upgrade.html#cloning-element-queries" rel="nofollow noreferrer">a change in Craft 3</a> and you need to <code>clone</code> your query (<a href="https://craftcms.com/docs/3.x/dev/functions.html#clone" rel="nofollow noreferrer">docs</a>).</p>
<p>I have not tested this but the below should work:</p>
<pre><code>{% set blocks = entry.nutritionBuilder %}

{% set item = clone(blocks).type('blockCalories').one() %}
{{ item.nutritionValue }}

{% for block in clone(blocks).level(1).all() %}
    ...
{% endfor %}
</code></pre>

CC BY-SA 4.0
2020-10-15T08:24:54.463Z
2020-10-16T04:56:52.727Z
2020-10-16T04:56:52.727Z
Oli
<p>I have blocks set up for nutritional values: Calories, Total Fat, Carbohydrates, etc. These are set up in NEO blocks.</p>
<p>I can successfully loop through all of the NEO blocks (about 20 rows total) and output the content using this for loop:</p>
<pre><code>{% for block in entry.nutritionBuilder.level(1).all() %}
    ...
{% endfor %}
</code></pre>
<p>Later, I added a line ABOVE this loop to retrieve the content of a single block:</p>
<pre><code>{% set item = entry.nutritionBuilder.type('blockCalories').one() %}
{{ item.nutritionValue }}
</code></pre>
<p>This works, in that it will output the value I need to retrieve. However, the for loop below this line now only outputs a single row from nutritionBuilder which is blockCalories row.</p>
<p>Can anyone see why this is happening?</p>

<forloop><plugin-neo>
Why does getting a single block in NEO prevent getting the remainder of the blocks?
# Why does getting a single block in NEO prevent getting the remainder of the blocks?

(Asked by: username_0 on 2020-10-14)

I have blocks set up for nutritional values: Calories, Total Fat, Carbohydrates, etc. These are set up in NEO blocks.
I can successfully loop through all of the NEO blocks (about 20 rows total) and output the content using this for loop:
{% for block in entry.nutritionBuilder.level(1).all() %}
    ...
{% endfor %}

Later, I added a line ABOVE this loop to retrieve the content of a single block:
{% set item = entry.nutritionBuilder.type('blockCalories').one() %}
{{ item.nutritionValue }}

This works, in that it will output the value I need to retrieve. However, the for loop below this line now only outputs a single row from nutritionBuilder which is blockCalories row.
Can anyone see why this is happening?

**Tags:** forloop, plugin-neo


---

## 2 answers

### Answer by username_0 on 2020-10-15. Score: 0 | Accepted answer

username_1, thanks for pointing me in the right direction. Your answer was close, but there's a slight modification:
{% set blocks = entry.nutritionBuilder %}

{% set item = clone(blocks).type('blockCalories').one() %}
{{ item.nutrionValue }}

{% for block in clone(blocks).level(1).all() %}
...
{% endfor %}

The cloning needs to happen when setting the item variable as well as in the for loop.

> **Comments:**
> **username_1**: Ha, too quick :) I've corrected the answer.  

---

### Answer by username_1 on 2020-10-15. Score: 2

This is because of a change in Craft 3 and you need to clone your query (docs).
I have not tested this but the below should work:
{% set blocks = entry.nutritionBuilder %}

{% set item = clone(blocks).type('blockCalories').one() %}
{{ item.nutritionValue }}

{% for block in clone(blocks).level(1).all() %}
    ...
{% endfor %}


---

