-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
how to select and transform data from structures #8
Comments
This works for me |
thanks @kms-rscholz |
i can not get it to work. fields:
action:
label: Aktionen
type: structure
fields:
link:
type: text
required: true
title:
type: text
required: true {
"query": "page('somepage')",
"select": {
"thisworksbutnofieldmethods": "page.action.yaml",
"thisdoesnotwork": {
"query": "page.action.toStructure",
"select": {
"link": "structureItem.link",
"title": "structureItem.title.html"
}
}
}
} |
"actions": {
"query": "page.action.toStructure",
"select": {
"link": true,
"title": true
}
} does work. but it seems to me |
I feel like If we consider toStructure from the field methods documentation to be the right method, this actually works (as you pointed out). As in the following example, I have a structure field called "items", so to correctly convert to an JSON structure, the items property looks like this: {
"select": {
"title": true,
"id": true,
"slug": true,
"items": "page.items.toStructure"
}
} |
I justed tested this an This works for me: // mediaStructure => name of the structure field
// mediaImage => name of the image/files field of mediaStructure
// structureItem => seems to be the reference for the query inside mediaStructure query
query: "page('projects/" + params.slug + "')",
select: {
title: true,
id: true,
mediaStructure: {
query: 'page.mediaStructure.toStructure',
select: {
mediaImage: {
query: 'structureItem.mediaImage.toFile'
}
}
}
} Could we make this part of the documentation? That would be great! Happy to help out if needed. |
I have a similar issue with values from a multiselect field… const query = {
query: `site.children.filterBy('uid', 'projekte').first`,
language: this.$i18n.locale,
select: {
title: true,
uid: true,
projects: {
query: 'page.children.listed',
select: {
title: true,
uid: true,
uri: true,
year: true,
student: {
query: 'page.student.split',
select: {
// this will return null
autoid: {
query: 'arrayItem.value',
},
},
},
},
},
},
} |
+1 |
i tried field.toArray and field.toStructure combined with arrayItem and structureItem like in query language but that did not work. best i could find out was to use field.yaml or a custom pagemethod.
i would love to see support for arrayItem and structureItem in kql since that would be most consistent imho.
The text was updated successfully, but these errors were encountered: