Select field with query options from another page structure

Hello everyone,

I have a problem fetching a list of people in a select field in my blueprint.
It seems to me to have tried everything but I can’t make it work. What am I doing wrong?

I have a page with template “people” (direct child of site) where I put all the people’s informations.
Now I need to fetch the people list in another page.

Below the two blueprints interested parts:

template people

title: Persone
icon: users
options:
  delete: false
  status: false
pages: false

columns:
  left:
    width: 3/4
    sections:
      content:
        type: fields
        fields:
          people:
            label: Lista delle persone
            type: structure
            fields:
              name:
                label: Nome
                type: text
                required: true
                width: 1/2
              lastName:
                label: Cognome
                type: text
                required: true
                width: 1/2

template class

title: Corso
icon: calendar
fields:
  description:
    label: Descrizione del corso
    type: markdown
    size: small
  appointments:
    label: Prossimi appuntamenti
    type: structure
    fields:
      classDateBegins:
        label: Data di inizio corso
        type: date
        default: now
        width: 1/2
      classDateEnds:
        label: Data di fine corso
        type: date
        width: 1/2
        help: Se il campo viene lasciato vuoto il corso avrà la durata di un solo giorno
      classTeacher:
        label: Insegnante
        type: select
        options: query
        query:
          fetch: site.children.template("people").people.toStructure
          text: "{{ structureItem.name }}"

BTW I also tried different stuff such as

fetch: page("people").people.toStructure
and
fetch: site.index.filterBy("template", "people").people.toStructure

fetch: site.find("people").people.toStructure
text: "{{ structureItem.name }}"
value: "{{ structureItem.name }}"

The page helper doesn’t work in blueprints.

Your filter attempts return a collection, not a single page.

Hi texnixe,

Thanks for your reply.
Unfortunately it still doesn’t work, I really don’t know why! :’(

I just tried a bunch of stuff, see below:

I swear that the blueprint people exists

Schermata 2019-12-15 alle 12.49.07

Now if I write what you suggest

query:
  fetch: site.find("people").people.toStructure
  text: "{{ structureItem.name }}"
  value: "{{ structureItem.name }}"

Absolutely nothing happen!

I’m struggling with this thing!!

Ah, your page is not called “people” but “persone”.

fetch: site.find("persone").people.toStructure

Find() needs the id of the page.

Or:

fetch: site.children.findBy("intendedTemplate", "people").people.toStructure
1 Like

Oh shit, I was absolutely sure that I had to call the template name, not the actual page name.
How stupid… I lost an hour trying to make this work. I guess I’m not going to do the same mistake again! :wink:

Thank you so so so much for your help and your time.
Of course it works perfectly now.

1 Like

Yeah, it is maybe better if I use the second option, the one with the template.
This way if the client decides to change the url of the page everything will still work.

Really really really thanks!!!

Sí, è più sicuro.

:smiley:
Grazie Sonja!