I’ve been crawling the forum for a solution but I can’t seem to get this to work with my extremely limited knowledge of PHP…essentially it’s a list of events that each have a start date and end date. What I have right now is that upon landing, every upcoming event is shown.
What I’d like to achieve is some way to toggle between showing events happening during: 1) the current day, 2) a week from the current day, and 3) a month from the current day, with the default view being the week view. Ideally this would take into account the start date and end date of each event as well. I imagine the navigation being either a set of radio buttons or a drop down menu that reloads the page with the correct date range on change.
Everything I’ve gleaned so far seems to employ params as a filtering method but from what I understand, params refer to specific dates rather than relative dates? Or is it possible to to pull the current time, add 24 hours or 7 days or 30 days to that time, and apply it as a range to a param?
All help is highly, highly appreciated, thank you for your time!
If “thismonth” or “thisweek” is not supposed to be a single day, but a date range, then you have to get the start and end days of these periods and filter by those.
Example:
This week is from today until 7 days later (but we exclude today in the filter):
This is probably a dumb question but does this go into a controller…? I keep running into the unexpected error page. I tried putting it straight into the template as well, right before looping an event snippet, is that a problem?
I think it was because a semi-colon was missing after the $thisWeekEnd variable in your last code block!
How would I go about taking the enddate into account as well? Like even though an event may not have a startdate in the week, it might still be happening during the week. Would it be creating an array for all of the dates between the event’s startddate and enddate and filtering all of them?
And how would I go about selecting the week filter by default on the events page load? Would it be routing?