Customizing the view for event recurrences

When I list events by www.xyz.td/events I get a list of the events including their recurrences.
But when I go into an event, the view that I had customized for events is only called for the original event. For its recurrences another view is used, that I cant't find to be customized as well.
(I related my customized template to events as default view thru ZMI protal_types)
We run PLONE 5.2
Any Hints? Thanks.

here is what id did in a plone4.3 project

  • if you have different event types that support occurences
    -> provide a view that redirects to the proper view

  • register your custom view for occurences

if you do not have several types of event, registering your custom view for IOccurence using the name occurrence_view probably is sufficient

example code - ymmv:

    <browser:page
        for="plone.event.interfaces.IOccurrence"
        name="event_view"
        class=".eventview.EventView"
        template="eventview.pt"
        permission="zope2.View"
        layer="my.types.browser.interfaces.IThemeSpecific" />

 <browser:page
      for="plone.event.interfaces.IOccurrence"
      name="occurrence_view"
      class=".eventview.OccurrenceView"
      permission="zope2.View"
      layer="my.types.browser.interfaces.IThemeSpecific"
      />

class OccurrenceView(BrowserView):
    """can handle occurrences of events and churchservices
    (plone.app.event returns occurrences for both, eventtype1 and eventtype2)
    """

    def __call__(self):
        # find out which type of event
        # and use the correct detail view
        acc = IEventAccessor(self.context)
        if acc.event_type == 'EventType1':
            view = api.content.get_view(
                'event_view', self.context, self.request)
        else:
            view = api.content.get_view(
                'event2_view', self.context, self.request)
        return view()

I have a very similar problem. We have a website with Plone 5.1.

I have managed to display the occurrences in a single event. When I search for events with a collection, the occurrences are also displayed. But in the search via python, the occurrences are not displayed.

<tal:search tal:define="results python:here.portal_catalog.searchResults(
        portal_type=(['Event']),
        sort_order='ascending',
        sort_on='start');

How can I search the occurrences with a portal_catalog search?

When it comes to occurrences there are two important things:

  • the start/end indexes in the catalog are a DateRecurringIndex, that means, that the "occurrence" of the events are found with a catalog search within your start/end boundaries but you get the brain of the "original" event. The "real" occurrence object is not catalogued (this is in order to not bloat the catalog with a recurring event with open end for example)
  • to get the real occurrences there's a utility method in plone.app.event.base which is called get_events. This is a wrapper for the catalog query and if the parameter expand=True is set, it expands your events to the real occurrences. (see https://github.com/plone/plone.app.event/blob/master/plone/app/event/base.py#L69)

This utility method cannot be called from a template. You have to write a BrowserView class for this.

Thanks for the tip. I had already feared that. I haven't worked with my own views yet because it seems too complex.

Of course, the best solution would be one that could run similarly with Plone 6 with react. What would be a solution in Plone 6 with react? In Plone 5 there is at least the event listing, which outputs the occurrences in a collection. In Plone 6, I have not yet found a view that correctly outputs normal appointments or even occurrences in the listing.

volto-fullcalendar-block displays the recurrences correctly.

In order to display recurrent events, you need to add a catalog index and metadata column

I created a variation that displays event information on listing and searches, but I'm struggling with the same issue you have where the recurrence does not show in the right place on the calendar, for now, the event card displays "recurring event" until I can figure out how to show it in the right place based on the recurrence date not the start or end date/time.

1 Like