1

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?

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 Commented Dec 31, 2017 at 14:45

1 Answer 1

4

Try doing something like:

{% set nextBlock = block.getNext() %}

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.