1

I'm using Solspace Calendar,
When I create an event with it I use a related entry field called 'project'
to choose an entry from a section called projects
I can display the project title etc in the Calendar template,
however I want to display the projects event date when on the project page (reverse related)
I can't fathom how to construct a reverse related entry – being 'events' is neither an entry, user, asset etc as per this question: Related Entries I would like to understand if its even possible as for example - the plugin not being a section, this clearly won't work:

{% set relatedDates = craft.entries.section('events').relatedTo(entry) %} 

how would one grab the calendar event to begin with? Thanks

1
  • so basically the opposite of this (below) in that I have an entry field 'project' to use in the Calendar and can choose the project entry when I create an event, not choosing an event from a project like below: docs.solspace.com/craft/calendar/v2/overview/…
    – user2569
    Commented Mar 24, 2021 at 17:11

1 Answer 1

2

after reading and re-reading the docs got this working:

{% set relatedDates = craft.calendar.events.relatedTo(entry).all() %}

{% for relatedEventEntry in relatedDates %}
 {{ relatedEventEntry.title }} - {{ relatedEventEntry.startDate.format("l, F j, Y \\a\\t g:ia") }}
      ({{ relatedEventEntry.duration.humanReadable }})
      in {{ relatedEventEntry.calendar.name }} calendar.
      {% if relatedEventEntry.repeating %}
        Repeats {{ relatedEventEntry.readableRepeatRule }}
      {% endif %}
{% endfor %}  

this is called from the projects/_entry template

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.