<p>The solution is to wrap the event output in a conditional that compares the event startdate to now. I've updated the question to reflect this.</p>

CC BY-SA 3.0
2018-04-11T14:32:31.803Z
2018-04-11T14:32:31.803Z
Vaughn D. Taylor
<p>I'm trying to suppress display of expired events (events that occurred in the past) on the Solspace month calendar. I'm using the out-of-the-box templates included with Solspace Calendar for Craft. Initially, I thought that there would be a start and end range for the calendar.month function:</p>

<pre><code>{% set month = craft.calendar.month({
    date: targetDate,
    calendar: calendarHandle,
}) %}
</code></pre>

<p>But looking at the documentation, there are no parameters to pass. (<a href="https://solspace.com/craft/calendar/docs/calendar.month/" rel="nofollow noreferrer">https://solspace.com/craft/calendar/docs/calendar.month/</a>)</p>

<p>So, I looked at what is happening, and it seems that the start and end should be set on the event object (<a href="https://solspace.com/craft/calendar/docs/event/" rel="nofollow noreferrer">https://solspace.com/craft/calendar/docs/event/</a>)</p>

<p>In the month template, the event object is called here:</p>

<pre><code>{% for event in day.events %}
    {% include "cal/layouts/_event.html" %}
{% endfor %}
</code></pre>

<p>And this is what is returned:</p>

<pre><code>{% set classes = "" %}
{% set classes = classes ~ (event.allDay ? " all_day") %}

{% if event.multiDay %}
    {% set classes = classes ~ " multi_day" %}
    {% set classes = classes ~ (day.containsDate(event.startDate) ? " first_day") %}
    {% set classes = classes ~ (day.containsDate(event.endDate) ? " last_day") %}
{% endif %}

{% set style = "" %}
    {% if event.multiDay or event.allDay %}
        {% set style %}
    style="background-color: {{ event.calendar.lighterColor }} !important;
        border-color: {{ event.calendar.color }} !important;"
    {% endset %}
{% endif %}

{% if event.startDate.format('U') &gt; now|date('U') %}

&lt;div class="event tips{{ classes }}"{{ style }} data-toggle="popover"&gt;
        {% if event.multiDay %}
            &lt;a href="{{ siteUrl }}cal/event/{{ event.id }}/{{ event.repeating ? event.startDate.format('Y/m/d') }}"
    style="color: {{ event.calendar.contrastColor }} !important;"&gt;
                {% autoescape false %}
                    {{ day.containsDate(event.startDate) or day.containsDate(event.endDate) ? event.title : "&amp;nbsp;"|raw }}
                {% endautoescape %}
            &lt;/a&gt;
        {% else %}
            {% if not event.allDay %}
                &lt;span class="calendar-color" style="background-color: {{ event.calendar.color }};"&gt;&lt;/span&gt;
            {% endif %}
                &lt;a href="{{ siteUrl }}cal/event/{{ event.id }}/{{ event.repeating ? event.startDate.format('Y/m/d') }}"
                {% if event.allDay %}style="color: {{ event.calendar.contrastColor }};"{% endif %}&gt;
                    {{ event.title }}
                &lt;/a&gt;
        {% endif %}

    {% include "cal/layouts/_event_popover.html" %}
&lt;/div&gt;

{% endif %}
</code></pre>

<p>I assume this is where I would set a date range, but I'm not really clear where I would set it?</p>

<p>UPDATE: I managed to get this working by wrapping the event output in a conditional:</p>

<pre><code>{% if event.startDate.format('U') &gt; now|date('U') %}
</code></pre>

<p>I added this to the code above.</p>

<plugin-solspacecalendar>
How to suppress display of expired entries in Solspace month calendar?
# How to suppress display of expired entries in Solspace month calendar?

(Asked by: username_0 on 2018-04-11)

I'm trying to suppress display of expired events (events that occurred in the past) on the Solspace month calendar. I'm using the out-of-the-box templates included with Solspace Calendar for Craft. Initially, I thought that there would be a start and end range for the calendar.month function:
{% set month = craft.calendar.month({
    date: targetDate,
    calendar: calendarHandle,
}) %}

But looking at the documentation, there are no parameters to pass. (https://solspace.com/craft/calendar/docs/calendar.month/)
So, I looked at what is happening, and it seems that the start and end should be set on the event object (https://solspace.com/craft/calendar/docs/event/)
In the month template, the event object is called here:
{% for event in day.events %}
    {% include "cal/layouts/_event.html" %}
{% endfor %}

And this is what is returned:
{% set classes = "" %}
{% set classes = classes ~ (event.allDay ? " all_day") %}

{% if event.multiDay %}
    {% set classes = classes ~ " multi_day" %}
    {% set classes = classes ~ (day.containsDate(event.startDate) ? " first_day") %}
    {% set classes = classes ~ (day.containsDate(event.endDate) ? " last_day") %}
{% endif %}

{% set style = "" %}
    {% if event.multiDay or event.allDay %}
        {% set style %}
    style="background-color: {{ event.calendar.lighterColor }} !important;
        border-color: {{ event.calendar.color }} !important;"
    {% endset %}
{% endif %}

{% if event.startDate.format('U') > now|date('U') %}


        {% if event.multiDay %}
            
                {% autoescape false %}
                    {{ day.containsDate(event.startDate) or day.containsDate(event.endDate) ? event.title : " "|raw }}
                {% endautoescape %}
            
        {% else %}
            {% if not event.allDay %}
                
            {% endif %}
                
                    {{ event.title }}
                
        {% endif %}

    {% include "cal/layouts/_event_popover.html" %}


{% endif %}

I assume this is where I would set a date range, but I'm not really clear where I would set it?
UPDATE: I managed to get this working by wrapping the event output in a conditional:
{% if event.startDate.format('U') > now|date('U') %}

I added this to the code above.

**Tags:** plugin-solspacecalendar


---

## 1 answers

### Answer by username_0 on 2018-04-11. Score: 2 | Accepted answer

The solution is to wrap the event output in a conditional that compares the event startdate to now. I've updated the question to reflect this.


---

