Add docs for chunking in Antlers
Applies to the collection tag but also could be assets fields etc.
For https://github.com/statamic/cms/pull/9157
Dumping stuff I tested with:
{{? $chunked_count = 0 ?}}
{{ field chunk="3" }}
<div class="border p-4 mb-4">
<b>Chunk {{ count }}/{{ total_chunks }}/{{ total_items }}</b>
{{ chunk }}
{{? $chunked_count++ ?}}
<li><a href="{{ url }}" class="text-teal font-medium text-lg mb-4">{{ title }}</a> ({{ chunked_count }}/{{ total_items }})</li>
{{ /chunk }}
</div>
{{ /field }}
Where {{ field }} is either {{ collection:some_collection }} or {{ some_query_builder }} (like an assets fields).
chunked_count is a way to count items across chunks as count in a chunk would only go 1-2-3-1-2-3-1-2-3...
Added in #1473
I've just had a quick look... I can't see where this was added. I can see the docs for the chunk modifier (but that's a slightly different thing).
Maybe I missed something though - that diff is pretty large! 😄
Probably a misunderstanding on my part, but I can't see the difference between what the chunk modifier does using that example and the code example here.
The only thing I can see that's missing is documentation around chunk_key.
They look similar, but they are slightly different.
One lets you chunk items in an array, and the other lets you chunk items from a query builder (which is what you're dealing with in the {{ collection }} tag).
We probably need to add an example of the chunk parameter to the collection/taxonomy tag docs.