solspace / craft-calendar

Calendar for Craft: The most reliable and powerful event management plugin for Craft.
http://docs.solspace.com/craft/calendar/v5
Other
15 stars 16 forks source link

Grouping Events by Month/Week/Day - Twig Runtime Error #303

Closed danystad closed 3 months ago

danystad commented 4 months ago

Describe the bug or issue you're experiencing

Steps to reproduce

  1. Updated Calendar plugin from version 5.0.3 to 5.0.6
  2. Template code for Grouping Events by Month/Week/Day returns the following Twig Runtime Error:
Twig Runtime Error – [Twig\Error\RuntimeError](http://twig.sensiolabs.org/api/2.x/Twig/Error/RuntimeError.html)

Neither the property "events" nor one of the methods "events()", "getevents()"/"isevents()"/"hasevents()" or "__call()" exist and have public access in class "Solspace\Calendar\Library\Duration\WeekDuration".

Craft & Plugin Info (please complete the following information):

Additional context

All 3 examples (for months, week, day) provided on the documentation page for Grouping Events by Month/Week/Day show a similar Twig Runtime Error.

Month: Neither the property "events" nor one of the methods "events()", "getevents()"/"isevents()"/"hasevents()" or "__call()" exist and have public access in class "Solspace\Calendar\Library\Duration\MonthDuration".

Week: Neither the property "events" nor one of the methods "events()", "getevents()"/"isevents()"/"hasevents()" or "__call()" exist and have public access in class "Solspace\Calendar\Library\Duration\WeekDuration".

Day: Neither the property "events" nor one of the methods "events()", "getevents()"/"isevents()"/"hasevents()" or "__call()" exist and have public access in class "Solspace\Calendar\Library\Duration\DayDuration".

diegocosta-dev commented 3 months ago

Hi guys, I am facing this problem after updating to version "5.0.6".

Craft Version: 4.11.1

Error:

Neither the property "events" nor one of the methods "events()", "getevents()"/"isevents()"/"hasevents()" or "__call()" exist and have public access in class "Solspace\Calendar\Library\Duration\DayDuration".

Code:

{% set events =
     craft.calendar.events({
     rangeStart: 'today',
     rangeEnd: '+2 months',
     calendar: siteCalendar,
     limit: 3,
     loadOccurrences: 'next'
   })
%}

{% set groupedByDay = events.groupedByDay() %}
    {% for day in groupedByDay %}
      <li class="flex flex-col gap-2">
        <span class="text-xs font-bold uppercase text-primary-700">
          {{ day.startDate.format('D n/j') }}
        </span>
        {% for event in day.events %}
          {% set eventUrl = event.url %}

        {% if event.repeating %}
          {% set eventUrl = eventUrl ~ '/' ~ event.startDate.format('Y-m-d')
          %}
        {% endif %}
        <a href="{{ eventUrl }}" class="text-[15px] leading-[19px]">
          {{ event.title }}
        </a>
    {% endfor %}
  </li>
{% endfor %}
kjmartens commented 3 months ago

This should be resolved in Calendar 5.0.7 now. 🙂