0

EE 2.8.1 Calendar 1.8.6

I want to only display the first occurrence of each repeating event.

Right now I have a list of all events always displaying the next upcoming occurrence.

{exp:calendar:cal calendar_id="{embed:calendar_id}" event_limit="{embed:event_limit}" date_range_start="today" show_months="6" pad_short_weeks="n" dynamic="off"}
<li><a href="{path='events/event'}/{event_id}/">{event_title} - Details >></a> {event_start_date format="%F %j, %Y"} 
{if event_summary}<br />{event_summary}{/if}
{if event_location}<br />Location: {event_location}{/if}
{if event_cost}<br />Cost: {event_cost}{/if}<br /><br />


</li>
          {if no_results}
          <li>No events could be found within the specified time range for this Calendar.</li>
          {/if}
{/exp:calendar:cal}
  • Try updating to 1.8.9. That's the latest version. Also turn on Template Debugging and check that calendar_id="" and event_limit="" are parsed correctly (i.e. are not showing {embed:...}). In particular, make sure you have event_limit="1" to show 1 event. Lastly, does your event start "today" or a date before that? In other words, is your first event before "today"? – Solspace Sep 3 '14 at 4:40
  • Yes it is more than likely that the event has started before today. Also if I have event limit set to 1 it will only show a single repeating event. I have numerous repeating events and I want to display the first event for each even if it has already happened. – Peter Eastwood Sep 3 '14 at 11:38
  • In that case, you might want to change the title of this thread from "...only display the first event of a recurring event" to "...only display the first event of each recurring event". Or even better "...only display the first occurrence of each recurring event within a set timeframe. I'll go ahead and make the edit to the title. – Solspace Sep 4 '14 at 1:00
1

The following solution, from the Solspace support site, might be what you are looking for:

How to display a chronological list of events, with each unique event appearing only once

It's also been mentioned in these threads:

Summary:

One approach is to use PHP to create an array of unique events, and display your event data only when the event is encountered for the first time in {exp:calendar:cal}. Here's an example (turn on PHP for your template and set it to Output):

{!-- Create the arrays --}
<?php 
    $event_ids = array();
    $event_data = array();
?>

{!-- 
    // Check if the event was already encountered (i.e. is in the array),
    // and store your data in a separate array if this is the first time
    // encountering this event 
--}
{exp:calendar:cal /* your other parameters here */}
<?php 
    if( ! in_array('{event_id}', $event_ids) )
    {
        $event_ids[] = '{event_id}';
        $event_data[] = '* The data you want displayed *';
    }
?>
{/exp:calendar:cal}

{!-- Display event data, still in chronological order --}
<?php 
    foreach($event_data as $data)
    {
        echo $data;
    }
?>

Of course there are likely other strategies, using PHP, Stash, or other means, but the main idea is to create a list/group/array of unique events within your timeframe.

| 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.