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!

Hi everyone,

it seems that I have a similar problem.

On an events page (events.yml) there are subpages (single events) and there is a structure for different event-sections. I want to query the structure items from the single event page (event.yml) in a select field, so one can select an event-section for a single event.

Blueprint events.yml:

title: Events
preset: page
pages: true
files: false
options:
  changeSlug: false

sidebar:
  fields:
    fields:
      meta_data: fields/meta_data
  pages:
    headline: Events
    templates:
      - event
    text: "{{ page.title }}"
    empty: Bisher keine Events.
    options:
      changeTemplate: false

fields:
  events_sections:
    label: Event Unterteilungen
    type: structure
    translate: false
    columns:
      section_name:
    fields:
      section_name:
        label: Name
        type: text
        width: 1/3
      marquee_text:
        type: text
        label: Marquee Text
        width: 1/2
      autoid:
        type: hidden
        translate: false

Blueprint event.yml

title: Event
preset: page
pages: false
files: false

fields:
  autoid:
    type: hidden
    translate: false
  events_section:
    type: select
    options:
      type: query
        fetch: site.children.findBy("intendedTemplate","events").events_sections.toStructure
        text: "{{ item.section_name }}"
        value: "{{ item.autoid }}"

I filled up the structure with different items, but in the panel the select field still is empty.

Glad for any help here! :face_holding_back_tears:

I didn’t test it, but I think Your indentation doesn’t look right.
Shouldn’t it be:

events_section:
  type: select
  options:
    type: query
    query: site.children.findBy("intendedTemplate","events").events_sections.toStructure
    text: "{{ item.section_name }}"
    value: "{{ item.autoid }}"

PS: Your “events” page must be published, or alternatively You can fetch draft pages with:

query: site.childrenAndDrafts.findBy("intendedTemplate","events").events_sections.toStructure

Wahh, you are totally right. Mixed up to many query language possibilities…
Thanks a lot!!!

1 Like