Hello,
I am using the KQL plugin and I want to get all products as well as the related categories.
I am sending the following query:
const res = await axios.post("/query",
{
query: "site",
select: {
title: "site.title",
url: "site.url",
products: {
query: "page('products').children.listed",
select: {
id: true,
title: true,
category: {
query: "site.category",
select: {
headline: "category.headline",
}
},
}
},
}
}
);
Now I want to rerieve all products including the headline of the related category of that product, but I am getting null for the category headline: category: {headline: null}
This is my category.yml file:
# Each page blueprint must have a title, the title may be different from the file name
title: Category
# Each page can have an icon that is shown in page listings when no preview image is available.
icon: 🖼
status:
draft: true
listed: true
columns:
- width: 2/3
# This columns only has a single field
fields:
headline:
label: Headline
type: text
And this is my product.yml file:
# Each page blueprint must have a title, the title may be different from the file name
title: Product
# Each page can have an icon that is shown in page listings when no preview image is available.
icon: 🖼
status:
draft: true
listed: true
columns:
- width: 2/3
# This columns only has a single field
fields:
text:
type: blocks
sent: fields/visitors
category:
label: Category
type: pages
query: site.find('categories')
multiple: false
- width: 1/3
# This second column holds a fields section with multiple fields
# More about fields sections: https://getkirby.com/docs/reference/panel/sections/fields
sections:
meta:
type: fields
fields:
# If you need the same field in multiple locations, you can define them once and reuse whereever needed.
# Here we use a files field defined in `/site/blueprints/field/cover.yml`
cover: fields/cover
files:
type: files
template: blocks/image
What am I doing wrong?
EDIT -----------------------------:
I managed it now that the category ID that I have set in the panel is now correctly returned with this query:
{
query: "site",
select: {
title: "site.title",
url: "site.url",
products: {
query: "page('products').children.listed",
select: {
id: true,
title: true,
category: true
}
},
}
}
But now I need to know how to actually get the category headline within the product query.

