2

I have a calendar with lots of different events. Some are single days, some span for months, others recur on specific dates, and some others recur on specific dates but also span several days.

How would I display the date of an occurrence while it is in progress, otherwise display the next occurrence?

This is what I have now:

{exp:calendar:occurrences
    event_id="{event_id}"
    date_range_start="today"
    date_range_end="+ 1 year"
    occurrences_limit="1"}

    {if '{occurrence_start_date format="%d/%m/%Y"}' == '{occurrence_end_date format="%d/%m/%Y"}'}
        {occurrence_start_date format="%d/%m/%Y"}
    {if:else}
        {occurrence_start_date format="%d/%m/%Y"} - {occurrence_end_date format="%d/%m/%Y"}
    {/if}
{/exp:calendar:occurrences}

This works most of the time, but breaks when there are recurring events spanning multiple days. For example, an event which recurs "every other weekend" will be displayed properly until Sunday, since the occurrence start date is Saturday.

1

In a number of cases involving getting event data within a specific timeframe, the recommended tag to use is {exp:calendar:cal}. This is the only tag that displays multi-event occurrence listings in full chronological order. More information on the use of the main Calendar tags can be found here: http://www.solspace.com/docs/calendar/getting_started/

I would then use conditionals to compare {event_start_date}, which will be the start date of the currently looped occurrence with EE's native {current_time}, which displays the current time. You might also want to check if {current_time} is in between {event_start_date} and {event_end_date} to display events that are currently in progress.

| improve this answer | |

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.