How to get the values of nested blueprints

Hello there

Currently I have in the agenda.yaml file this code:

header.agenda:
     type: list
     style: vertical
     label: Lista de eventos
     fields:
        .mes:
            type: text
            style: vertical
            label: Mes
        .eventos:
            type: list
            style: vertical
            label: eventos
            fields:
              .evento_dia:
                  type: number
                  label: Dia del evento
                  size: small
                  validate:
                     min: 1
                     max: 31
              .evento_titulo:
                  type: text
                  label: Título del evento
              .evento_descripcion:
                  type: textarea
                  label: Descripción del evento
                  rows: 3
                  markdown: true
                  maxlength: 255

I can get the mes value in the agenda.html.twig with:

{% for item in page.header.agenda %}
  ....
  <p>{{item.mes}}</p>
   ....
{% endfor %}

But I don’t know how I can get the eventos items. I’ve probed with (this is a piece of code):

{% for item in page.header.agenda.eventos %}

{{item.evento_dia}}

.... {% endfor %} ``` But no results.

In agenda.md file I have this:

---
title: 'Agenda 2022'
body_classes: modular
wrapper_classes: style1
agenda:
    -
        mes: Septiembre
        eventos:
            -
                evento_dia: 1
                evento_titulo: 'evento 1'
                evento_descripcion: 'Lorem ipsum dolor vestibulum ante ipsum primis in faucibus vestibulum. Blandit adipiscing eu felis iaculis volutpat ac adipiscing accumsan eu faucibus. Integer ac pellentesque praesent'
                evento_lugar: Madrid
                evento_duracion: '90 minutos'
---

I’d like to get all values of eventos items. Is this possible with for loops or I will need something like arrays?

Thanks in advance.

Same as you loop through agenda list, you should also loop through each agenda item eventos list:

{% for item in page.header.agenda %}
  <p>{{item.mes}}</p>
  {% for evento in item.eventos %}
    <p>{{evento.evento_titulo}}</p>
  {% endfor %}
{% endfor %}
1 Like

Thank you so much, @Karmalakas

It’s a very simple solution.