1

Each entry has a matrix field with fields including start date, end date, location etc

I need to list and display only the entries after now.

I am able to filter them by

{% set queryEntries = craft.entries({
    section: ['events'],
}) %}

{% for entry in queryEntries.all() %}
    {% if entry.eventDetails.dateFrom|date("U")  > "now"|date("U") %}
        {{ entry.title }}
    {% endif %}
{% endfor %}

This isn't great though as when the events list grows it won't be very performant and I have entries that I don't want.

Am I am able to filter the queryEntries by entry.eventDetails.dateFrom|date("U") > "now"|date("U") ?

DumbDevGirl42069
  • 891
  • 5
  • 18
  • 47
  • 3
    Twig is a templating language, so it is not meant for that. You should do this processing when you query your models collections at a controller level rather. – β.εηοιτ.βε Nov 11 '20 at 23:46
  • 2
    just do the logical part in your `PHP code section` and pass the variable to twig, you do not want to do logical things in twig. – Hardik Satasiya Nov 12 '20 at 07:16

0 Answers0