Blueprint: Query fields from multiple pages?

Hey there!

I would like to feed a “tags” field with content from all the instances of a particular “structure” field across multiple pages of the same template:

site.children.filterBy(“intendedTemplate”, “category”).items.toStructure

This won’t work, as it looks like the query can only process the field contents of a single page.

Is there a solution for this, or will I just have to structure my content differently to avoid this requirement?

Thanks a bunch! : )

You need a custom page method for this, that collects all the tags of all the pages structure fields into a single tags array.

Alright, thanks for pointing me in the right direction (and for replying as quickly as always). : )

Kirby::plugin('my/site-methods', [
    'siteMethods' => [
        "getItems" => function () {
            $categories = $this->children()->filterBy("intendedTemplate", "category");
            $items = new Structure();
            foreach ($categories as $category) {
                //Merge and prep structure fields according to requirement.
            return $items;