Displaying Only Future Events

Is there a liquid code to display only future events in a list?

@Alex_B_Centrifuge did these examples which is awesome.
Might give you something to work with? :slight_smile:

1 Like

Thank you, I will give it a try today!

1 Like

This will work as well (example using searchScope):

{% assign current = "now" | date: '%Y-%m-%d' %}

{% component source: "Event", layout: "List", searchScope: '{"prop_EventDateStart_Min":"{{current}}"}', sortBy: "EventDateStart", sortOrder: "ASC", limit: "5", emptyMessage: "<p class='cell'><em>Sorry, no events available at this time</em></p>", type: "module" %}

Basically, using now to set the current date (YYYY-mm-dd). Then filtering searchScope from the Event Date Start (minimum date), then sorting by Event Date Start.

You can also use this with Custom Modules (use Search Form code to gather the date start (if you created one)).

This liquid works really well, and helps with load time as well.

A.

1 Like

Thank you! It works perfectly!

1 Like

You can simplify this by eliminating the “Assign” and putting this directly in the component tag.

Just change:

searchScope: ‘{“prop_EventDateStart_Min”:“{{current}}”}’,

to

searchScope: ‘{“prop_EventDateStart_Min”:“{{ ‘now’ | datetime }}”}’,

Do me a favor and create an event that starts today at midnight and see if it displays doing what you have already done or what I have shown you? Results should be the same either way. I had a time issue and everything was 6 hours off because of my time zone. Central time is -6:00 UTC so it would never display anything before 6:00 AM. For most things this is probably fine because what is going on before 6:00 am. To solve this issue I did the following…

searchScope: ‘{“prop_EventDateStart_Min”:“{{ ‘now’ | datetime | date_add: -6, ‘hour’ }}”}’,

Now it displays everything from Midnight. Note there is no "date_minus so you have to add a negative number.

Update: This time bug will be fixed in 5.9.2

1 Like