Dynamic filter by date

Hello,

I want to show events that happen today or in the future by default. I have managed to do that pretty easily with ->filterBy('date', 'date >=', 'today') but I want the user to be able to deactivate the filter to access archived past events.

I have followed this tutorial to create category filters which work very well but I can’t figure out how to make the same thing work for dates.

Could someone walk me through it? I am very new to all this.

Depends how you want to implement this on the frontend? All on the same page? A filter? A link to archived events?

I was thinking a filter with two buttons, one labelled “Past events” and the other “Future events”. The “Future events” one would be active by default.

The all you need is to append a parameter to the button link, filter:past or something like that, then in your controller, check if the parameter is set and filter by date or not