Forum

Thread tagged as: Question, Addons

Events App - filter/match based on end date

Hullo!

I am currently using the Events app to display... events. Because multi-day events are a possibility for this project (as in, events that start on one day and finish a few days later), I've added a new field to the template, eventEndDateTime.

I'm currently using perch_events_custom to display a list of upcoming events. Like so:

<?php
    perch_events_custom(array(
    'template' => 'listing/event-sidebar.html',
    'filter'=>'eventDateTime',
    'match'=>'gte',
    'value'=>date('Y-m-d'),
    'sort'=>'eventDateTime',
    'sort-order'=>'ASC',
    'count' => 3,
    ));
    ?>

This works great, except on the multi-day events: once the start date has passed, the event is no longer displayed (which is what I'd expect with the above code). What I'd like to do is continue to display the events if they are "in progress", and stop displaying the events only after the end date has expired.

Like this:

<?php
    perch_events_custom(array(
    'template' => 'listing/event-sidebar.html',
    'filter'=>'eventEndDateTime',
    'match'=>'gte',
    'value'=>date('Y-m-d'),
    'sort'=>'eventEndDateTime',
    'sort-order'=>'ASC',
    'count' => 3,
    ));
    ?>

However, this new markup doesn't give the desired result (which is to say, nothing "matches" therefore nothing is output to the page). I assume it's to do with the value line - perhaps the date variable is baked-in to the Events app itself, and directly tied to eventDateTime.

I wonder if the solution lies somewhere in Passing a Variable... somewhere, but to be honest I can't quite wrap my head around this one.

Any help would be greatly appreciated!

Richard Terrick

Richard Terrick 3 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The Events app doesn't currently have support for filtering on dynamic fields. That change is coming.

Oh Drew, you've become such a tease with all your hints of an upcoming Events app. All I can say that I'm looking forward to it immensely.

Any update on this? Would love to sort by date range for Future, Current and Past events.

For example, would something like this be possible?

perch_events_custom(array(
    'filter'=>'eventDateTime',
    'match'=>'eqbetween',
    **'value'=>'eventDateTime, endDate',**
    'count'=>20,
    'sort'=>'eventDateTime',
    'sort-order'=>'asc',
    'template'=>'listing/custom-listing-day.html',
    'past-events'=>false
));
Rachel Andrew

Rachel Andrew 394 points
Perch Support

When we have an updated Events App it will be announced here: https://grabaperch.com/news

Thanks Rachel and Drew,

I'm curious if this could be solved by using PHP to parse the start date and end date and adding an if statement to check if current date is between those two. Does that sound doable with the current version of the Events App?

Thanks & I'll post back if I do find a solution for this.

Best, Tommy

Hi Tommy, I'm interested to know if you got anywhere with this issue? Thanks.

I ended up using Pages and a bit of hard code but am looking forward to the Events update. Let me know if you end up making any progress! T

Me too, I have told 2 clients using the Events app that its coming... do you have an estimated date for release