peterp
March 29, 2019, 9:50am
1
Hi all,
i want to use the data from a structure field of a second page in a select.
options: query
query:
fetch: home.categories.toStructure
text: "{{ structureItem.text }}"
value: "{{ structureItem.key }}"
does not work, any ideas?
thx
You have to tell Kirby what home
is…
fetch: site.find("home").categories.toStructure
peterp
March 29, 2019, 10:10am
3
same result: the selectbox shows: “{{ structureItem.text }}”
it is a child page from home: page.parent.categories.toStructure does not work ,too.
So in which page exactly is the field? You have to pass the path to the right page. If it is not in the home page, then the above will not work, of course.
And what are the fields in the structure field called?
peterp
March 29, 2019, 10:18am
5
the fields are:
key:
label: kex
type: text
text:
label: text
type: text
the page is in home/about
i want to get data from the home field in the home/about page.
Then
fetch: site.index.find("home/about").categories.toStructure
Or to prevent using index
fetch: site.find('home').children.find('about').categories.toStructure
peterp
March 29, 2019, 10:23am
7
sorry… the structure field i want to get the data from is in home.
and in home/about i want to select the data from the structure field of the home page.
so: site.find(“home”). should be correct but gives the result above.
Then please post the blueprint of the home page. It doesn’t matter where you want to fetch the data but where you want to fetch it from.
peterp
March 29, 2019, 10:28am
9
this is the structure field in the home blueprint.
categories:
label: Kategorien
type: structure
style: table
required: true
fields:
key:
label: kex
type: text
text:
label: text
type: text
sequence:
label: Reihenfolge
type: number
The what I originally posted above should work. But maybe your indentation for the select field is wrong.
It should look like this, i.e. with options
and query
on the same level in the indentation hierarchy.
fieldname:
label: Select field
type: select
options: query
query:
fetch: site.find('home').categories.toStructure
text: “{{ structureItem.text }}”
value: “{{ structureItem.key }}”
In the future, could you please wrap blocks of code within 3 backticks on a new line before and after the code block.
1 Like
peterp
March 29, 2019, 11:51am
11
Hi,
lol it works with your code. It was my blueprint formatting. And yes i’ll wrap the code.
thanks for your help!