Query number of collection item in blueprint

So I have a page structure of:

1. Parent
    1. Child
    2. Child
    [...]
2. Parent
    1. Child
    2. Child
    [...]
3. Parent
    1. Child
    2. Child
    [...]

I’d like to display the index number of each child as info in the panel pages section.

info: "{{ page.indexOf(page.parent.siblings.children) }} " works fine, but as expected it starts from 0 and not 1.

Arithmetics won’t work in the blueprint and num() doesn’t work for collections, only pages.

Any ideas how to shift the query so it starts counting from 1?

A pages section always has children of one parent only? Or are you using the pagesdisplay plugin?

You can move that code into a custom page method, then use that instead of doing math in the blueprint.

You can move that code into a custom page method, then use that instead of doing math in the blueprint.

Of course! :person_facepalming: I always forget about those. Here’s what I ended up with:

'cousinIndexNum' => function() {
    $cousins = $this->parent()->siblings()->children();
    return $this->indexOf($cousins) + 1;
}

and in the blueprint

info: "{{ page.cousinIndexNum }} "

Many thanks for the lighting fast support!