1

I would like to get the events with all their occurrences that belong to a specific month but ignore any of those occurrences before a certain date. From the documentation, the dateRangeStart parameter should the trick but it doesn't work for me. The following query returns all events starting from December 1st.

{% set month = craft.calendar.month({
    dateRangeStart: '2017-12-17',
    calendar: calendarHandle
}) %}

Any help?

1 Answer 1

1

The calendar.month function is designed to only display complete months, so as long as you specify a date, it's going to show you events for that whole month (before and after).

What you're looking for is the calendar.events function: https://solspace.com/craft/calendar/docs/calendar.events/

The code to display events starting from today plus 1 month (+30 days) would look something like this:

{% set events = craft.calendar.events({
   dateRangeStart: 'today',
   dateRangeEnd: '30 days'
}) %}

If you're looking to display events starting today but stop and the END of the current month, your code would look something like this:

{% set events = craft.calendar.events({
   dateRangeStart: 'today',
   dateRangeEnd: 'last day of +0 month'
}) %}
2
  • Thank you for the reply. I'm a bit confused by this. What is the purpose of the dateRangeStart and dateRangeEnd as mentioned in the documentation for craft.calendar.month? The reason I'm asking is that I want to output the events of a specific month grouped by days as in {% for week in month %} {% for day in week %} ... which from what I understand is not possible using craft.calendar.events. Commented Dec 18, 2017 at 9:38
  • Honestly, I think those are errors in the documentation. I will double check with our lead developer and then remove them. Sorry for the confusion.
    – Solspace
    Commented Dec 22, 2017 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.