Get objects (date field) from multiple pages (Twig)

Hi everyone,

I’m creating a website in which I have a “Calendar” page. On this page, I’d like to display the different events that are in the child pages of “Productions” in a calendar that I’ve created myself. An “Event” page (child of the “Productions” page) contains events with 3 fields (date, url and availability).

What I’d like to do is search for all the events in the “Event” pages and sort them by date.

I can easily access the information on these pages, for example:

{% set prods = pages.find('/productions').children().published() %}
{% for event in prods %}
  {{ event.url }}
{% endfor %}

But I can’t create a condition like:

if you find an event, in all the events, that happens on this date, then …

for example:

{% if|date("d.m.y") == " 10.09.24" %}
{% endif %}

How do I get my condition to pass through all the dates and choose the right one?

Thank you in advance for your help.

Edit: Here’s my blueprint:

              type: section
              title: "Dates"
              underline: true
                  type: list
                  label: "Add a date"
                  style: horizontal
                      type: datetime
                      label: "Date"
                      type: text
                      label: "Link to shop"
                      type: toggle
                      label: "Availabilty?"
                      highlight: 1
                      default: 1
                        1: Available
                        0: No longer available
                        type: bool

If your {{ event.url }} works, shouldn’t you check for {{ }}?


  • Please show the frontmatter of the page containing the definition of the ‘dates’ variable.
  • And dump the following values in Twig so you’ll know what you are comparing with. Use:
    • {{ }}
    • {{|date("d.m.y") }}

Because my dates are in a list type field (see blueprint in my original post)

I added the blueprint of the child page in the post.
The thing is that one “Event” page can have multiple events. That’s why I use a list type field.

@ValTOP, Instead of making us trying to understand your blueprint, one or two sample frontmatters would so be much easier to grasp…

Sorry, here it is:

        date: '29-12-2024 17:00'
        url: ''
        available: true
        date: '12-09-2024 14:00'
        url: ''
        available: true
        date: '13-09-2024 16:00'
        url: ''
        available: false

@ValTOP, Did you try looping through the list of events?

{% for event in child.header.dates %} 
  {% if|date("d.m.y") == "29.12.24" %}
      {{ 'process event' }}
  {% endif %}
{% endfor %}