<p>Try doing something like:</p>

<pre><code>{% set nextBlock = block.getNext() %}
</code></pre>

<p><a href="https://craftcms.com/docs/templating/matrixblockmodel#getNext" rel="nofollow noreferrer">https://craftcms.com/docs/templating/matrixblockmodel#getNext</a></p>

CC BY-SA 3.0
2017-12-31T14:44:38.393Z
2017-12-31T14:44:38.393Z
andrew.welch
<p>I’m struggling with getting the next <code>block</code> inside of a loop of a Matrix-Field. I’ve tried this:</p>

<pre><code>{% set nextBlock = entry.articleContent.offset(1).limit(1) %}
{% if nextBlock.type == "textBox" %}
 {{ nextBlock.textTitle }}
{% endif %}
</code></pre>

<p>This produces an <strong>ArgumentCountError</strong>. Can someone help me with this issue?</p>

CC BY-SA 3.0
2017-12-31T14:45:09.163Z
Your `nextBlock` is currently an object of type `ElementCriteriaModel` so you have a query but you don't use it. In order to execute the search you need to use the `first()` function. Or you could use the `block.getNext()` function
Robin Schambach
<matrix><forloop><loop><previous-next>
Next block inside of a loop
# Next block inside of a loop

(Asked by: username_0 on 2017-12-31)

I’m struggling with getting the next block inside of a loop of a Matrix-Field. I’ve tried this:
{% set nextBlock = entry.articleContent.offset(1).limit(1) %}
{% if nextBlock.type == "textBox" %}
 {{ nextBlock.textTitle }}
{% endif %}

This produces an ArgumentCountError. Can someone help me with this issue?

**Tags:** matrix, forloop, loop, previous-next

> **Comments:**
> **username_1**: Your `nextBlock` is currently an object of type `ElementCriteriaModel` so you have a query but you don't use it. In order to execute the search you need to use the `first()` function. Or you could use the `block.getNext()` function  

---

## 1 answers

### Answer by username_2 on 2017-12-31. Score: 4 | Accepted answer

Try doing something like:
{% set nextBlock = block.getNext() %}

https://craftcms.com/docs/templating/matrixblockmodel#getNext


---

