0

This is for an event detail page, I'd like to list all recurrences of an event. My current template code is displaying the start date and all recurrences, including the first date, so it's showing the start date twice. Any way to not get it to do that? I can't just remove the event_start_date tag as some events will only have one day and no recurrances.

      {event_dates}
                    {calendar:event_start_date format="%l, %F %j, %Y"}
                        {if calendar:event_all_day}
                        {if:else}
                            {calendar:event_start_date format="%g:%i%a"} -
                            {if calendar:event_multi_day}
                                <br />{calendar:event_end_date format="%l, %F %j, %Y at %g:%i%a"}
                            {if:else}
                                {calendar:event_end_date format="%g:%i%a"}
                            {/if}
                        {/if}

                    {if calendar:event_recurs}
                        <br />
                        {calendar:recurrences
                            date_range_start="today"
                            date_range_end="18 months"
                            limit="5"
                            backspace="6"
                        }
                            {calendar:recurrence_start_date format="%l, %F %j, %Y"}
                            {if calendar:event_all_day}
                            {if:else}
                                {calendar:recurrence_start_date format="%g:%i%a"} -
                                {if calendar:event_multi_day}
                                    <br />{calendar:recurrence_end_date format="%l, %F %j, %Y at %g:%i%a"}
                                {if:else}
                                    {calendar:recurrence_end_date format="%g:%i%a"}
                                {/if}
                            {/if}
                            <br />{/calendar:recurrences}
                    {/if}
       {/event_dates}

The code above is returning this on the front end... front end display

And here are the event settings... cp event settings

1 Answer 1

1

Calendar is doing exactly what is expected here. To achieve what you're after (if I understand correctly), something you could consider trying is code like this:

   {event_dates}
      {if calendar:event_recurs}
         {calendar:recurrences
            date_range_start="today"
            date_range_end="18 months"
            limit="5"
            backspace="6"
         }
            {calendar:recurrence_start_date format="%l, %F %j, %Y"}
            {if calendar:event_all_day}
            {if:else}
               {calendar:recurrence_start_date format="%g:%i%a"} -
               {if calendar:event_multi_day}
                  <br />{calendar:recurrence_end_date format="%l, %F %j, %Y at %g:%i%a"}
               {if:else}
                  {calendar:recurrence_end_date format="%g:%i%a"}
               {/if}
            {/if}
            <br />
         {/calendar:recurrences}
      {if:else}
         {calendar:event_start_date format="%l, %F %j, %Y"}
         {if calendar:event_all_day}
         {if:else}
            {calendar:event_start_date format="%g:%i%a"} -
            {if calendar:event_multi_day}
               <br />{calendar:event_end_date format="%l, %F %j, %Y at %g:%i%a"}
            {if:else}
               {calendar:event_end_date format="%g:%i%a"}
            {/if}
         {/if}
      {/if}
    {/event_dates}

If the event recurs, it'll display the upcoming recurrences. If it's a regular event without recurrences, then it should show the regular event info. I haven't tested this, but it should work. :)

1
  • Thanks! switching the conditional around worked. So simple I should have thought of it. Dec 13, 2017 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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