1

I am trying to list 3 previous events but I'm not getting any results. Does anyone have any ideas?

{exp:calendar:events 
                            event_limit="3" 
                            status="open" 
                            date_range_end="today" 
                            show_weeks="10" 
                            orderby="event_start_date" 
                            sort="desc"
                            calendar_id="not 400|402"
                        }
                        <div class="col-xs-4 events-item">
                            <a href="{event_url_title}" class="image-block">
                                {event_images limit="1"}
                                <img src="{image:url:small}" alt="{event_title}">
                                {/event_images}
                            </a>
                            <div class="date">{event_start_date format="%M %j, %Y"} - {event_end_date format="%M %j, %Y"}</div>
                            <h3>{event_title}</h3>
                            <div class="description">
                                {event_snippet}
                            </div>
                            <a href="/events/{event_url_title}" class="blue">Read more</a>
                        </div><!-- /row events-item-->
                        {/exp:calendar:events}

1 Answer 1

1

Since you're looking to display 3 previous events based on a chronological timeline, you need to use {exp:calendar:cal}, not {exp:calendar:events}. The reason has been explain many times here on EESE, the old Solspace support forums, as well as summarized on this documentation page: http://www.solspace.com/docs/calendar/getting_started/

Something like this is a good start:

{exp:calendar:cal 
   date_range_start="3 days ago" 
   date_range_end="today" 
   pad_short_weeks="n"
   limit="3"}

However, this will give you three events/occurrences starting from 3 days ago. I assume you want 3 events/occurrences going back from today. In that case, you might need to create a PHP array, and pick the last three items in the array. Those would be the events/occurrences closest to your date_range_end.

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.