Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for chunking in Antlers #1289

Open
jasonvarga opened this issue Mar 22, 2024 · 4 comments
Open

Add docs for chunking in Antlers #1289

jasonvarga opened this issue Mar 22, 2024 · 4 comments

Comments

@jasonvarga
Copy link
Member

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

@miicah
Copy link
Contributor

miicah commented Feb 20, 2025

Added in #1473

@duncanmcclean
Copy link
Member

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! 😄

@miicah
Copy link
Contributor

miicah commented Feb 20, 2025

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.

@duncanmcclean
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants