statamic / docs

Statamic Documentation

Home Page:https://statamic.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add docs for chunking in Antlers

jasonvarga opened this issue · comments

Applies to the collection tag but also could be assets fields etc.

For statamic/cms#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...

CleanShot 2024-03-22 at 10 57 16