0

I'm displaying events as a list (per day) but finding that if a day has more than one event, the day is duplicated, so rather than: 1 2 3 I'm getting 1 2 2 3 where there is more than one event on the 2nd, code is here:

<ul class=" calendar_list no-bullet">
                        {exp:calendar:cal 
                            {if segment_3 == ''}date_range_start="year-month-01" date_range_end="year-month-last"{/if}
                            {if segment_3 != ""}date_range_start="{segment_3}-{segment_4}-01" date_range_end="{segment_3}-{segment_4}-last" {/if}
                             {if segment_4 == "{current_time format="%m"}"}date_range_start="today" date_range_end="{segment_3}-{segment_4}-last"{/if}

                            pad_short_weeks="n" 
                            category="1" 
                        }
                             {if calendar_no_results}<h3>There are no events for this month</h3>{/if}
                            {!-- {if event_count=="1"}<h1>****{event_start_date format="%F %Y"} | {event_count}</h1>{/if} --} {!-- control date format here for month/year title --}
                            <li class="calendar_list"><h4>{event_start_date format="%j"}<br /><span class="list_month">{event_start_date format="%M"}</span></h4>{!-- control date format here for day/month sub-title i.e. %j = day  %F = month  --}
                                <p>{embed="_embeds/calendar_events_by_day" my_date="{segment_3}-{segment_4}-{event_start_date format="%d"}" event_cat_id="1"}</p>
                            </li>
                        {/exp:calendar:cal}
                    </ul>

and embedded code 'calendar_events_by_day' here:

{exp:calendar:events 
    date_range_start="{embed:my_date}" date_range_end="{embed:my_date}"
    category="{embed:event_cat_id}"
}
    <div class="{if event_type == "Event Type 1"}event_type1{/if}{if event_type == "Event Type 2"}event_type2{/if}{if event_type == "Event Type 3"}event_type3{/if}{if event_type == "Event Type 4"}event_type4{/if}">
    <a href="/{segment_1}/events/{url_title}" class="tips" data-toggle="tooltip" data-placement="top" title="{event_title}">**{event_title}</a><br />
    {if session!=""}{session}<br />{/if}{event_start_date format="%g"}{if event_start_minute > 0}:{event_start_minute}{/if}{if event_end_time != event_start_time && event_end_time != '00:00'}&ndash;{event_end_date format="%g"}{if event_end_minute > 0}:{event_end_minute}{/if}{event_end_date format="%a"}{if:else}{event_start_date format="%a"}{/if}<br /></div>
{/exp:calendar:events}

Any pointers appreciated!

1 Answer 1

0

Highly suggested reading to distinguish Calendar tags:

https://solspace.com/docs/calendar/getting_started/

You should only need {exp:calendar:cal} to display events for a day. No {exp:calendar:events}, no embeds.

Let's say you have this URL: http://example.com/calendar/events/2015/12/25

To display events on December 25th, 2015, you would need only this:

{exp:calendar:cal 
  date_range_start="{segment_3}-{segment_4}-{segment_5}"
  date_range_end="{segment_3}-{segment_4}-{segment_5}"
  pad_short_weeks="n"}

    {events}
        // Your event data
    {/events}
{/exp:calendar:cal}

(Add conditionals based on segment_X if you want something a bit more dynamic. {current_time} is a late-parsed variable, however, so might not parse early enough for the {exp:calendar:cal} tag)

If the range is more than 1 day and you want to display events for each day, you would add the {display_each_day}...{/display_each_day} tag pair around {events}...{/events} so that Calendar loops through each day.

1
  • Thanks will check out the guide, my situation requires the latter (more than 1 day and you want to display events for each day) as I want to avoid – example: 23 October repeating 2 times, i.e NOT 23 October Event 1 Event 2 --- 23 October --- Event 1 Event 2 --- BUT 23 October Event 1 Event 2 --- 24 October Event 1 --- etc Thanks
    – Kev N
    Commented Oct 23, 2015 at 13:29

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.