Is there a way to get the first and last days of a multi-day event? I want to be able to style the first and last days differently. I don't see anything like this in the docs.

This is in Craft 3 and Calendar 2.0.17


Within the context of calendar.month, if you check out the demo templates, we style the beginning and end of multi-day events with the following code:

{% if event.multiDay %}
    {% set classes = classes ~ " multi_day" %}
    {% set classes = classes ~ (day.containsDate(event.startDateLocalized) ? " first_day") %}
    {% set classes = classes ~ (day.containsDate(event.endDateLocalized) ? " last_day") %}
{% endif %}
  • Excellent! Thanks - I must've missed that in the demo templates. – Angie Herrera Mar 27 '19 at 15:51
  • This is almost fully working. The bit that doesn't work is the "first_day" class per your example. Even in the demo templates the class for the first day isn't applied. Any ideas? – Angie Herrera Mar 27 '19 at 21:57
  • Screenshot of the demo templates in my setup here: d.pr/i/a0T1BV – Angie Herrera Mar 27 '19 at 21:58
  • Perhaps try reinstalling demo templates. Multi-day events appear to display correctly for me... – Solspace Mar 28 '19 at 14:10
  • Hm, that didn't work. – Angie Herrera Apr 1 '19 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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