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?

  • 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 Dec 31 '17 at 14:45
3

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, privacy policy and cookie policy

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