Skip to main content
deleted 11 characters in body
Source Link
carlcs
  • 36.3k
  • 5
  • 63
  • 140

When you are setting nextEvent, you can limit only events that are upcoming and only output the first result you get back like so:

.startDate('>= ' ~ now).first()

So you can take that and update your code like so:

{% set nextEvent = craft.entries.section('events').order('startDate').startDate('>= ' ~ now).first() %}

{% for entry inif nextEvent %}
    foo
{% endforendif %}

I have assumed you have a section called 'Event's until we get some clarification as to what craft.events.events is.

When you are setting nextEvent, you can limit only events that are upcoming and only output the first result you get back like so:

.startDate('>= ' ~ now).first()

So you can take that and update your code like so:

{% set nextEvent = craft.entries.section('events').order('startDate').startDate('>= ' ~ now).first() %}

{% for entry in nextEvent %}
    foo
{% endfor %}

I have assumed you have a section called 'Event's until we get some clarification as to what craft.events.events is.

When you are setting nextEvent, you can limit only events that are upcoming and only output the first result you get back like so:

.startDate('>= ' ~ now).first()

So you can take that and update your code like so:

{% set nextEvent = craft.entries.section('events').order('startDate').startDate('>= ' ~ now).first() %}

{% if nextEvent %}
    foo
{% endif %}

I have assumed you have a section called 'Event's until we get some clarification as to what craft.events.events is.

Would be better to use the first() method instead of setting a limit.
Source Link
Jamie Wade
  • 3.6k
  • 2
  • 17
  • 32

When you are setting nextEvent, you can limit only events that are after today like so. This also limits theupcoming and only output to being the first result you get back like so:

.startDate('>= ' ~ now).limitfirst(1)

So the fullyou can take that and update your code would be along the lines oflike so:

{% set nextEvent = craft.entries.section('events').order('startDate').startDate('>= ' ~ now).limitfirst(1) %}

{% for entry in nextEvent %}
    foo
{% endfor %}

I have assumed you have a section called 'Event's until we get some clarification as to what craft.events.events is.

When you are setting nextEvent, you can limit only events that are after today like so. This also limits the output to being the first result:

.startDate('>= ' ~ now).limit(1)

So the full code would be along the lines of:

{% set nextEvent = craft.entries.section('events').order('startDate').startDate('>= ' ~ now).limit(1) %}

{% for entry in nextEvent %}
    foo
{% endfor %}

I have assumed you have a section called 'Event's until we get some clarification as to what craft.events.events is.

When you are setting nextEvent, you can limit only events that are upcoming and only output the first result you get back like so:

.startDate('>= ' ~ now).first()

So you can take that and update your code like so:

{% set nextEvent = craft.entries.section('events').order('startDate').startDate('>= ' ~ now).first() %}

{% for entry in nextEvent %}
    foo
{% endfor %}

I have assumed you have a section called 'Event's until we get some clarification as to what craft.events.events is.

Source Link
Jamie Wade
  • 3.6k
  • 2
  • 17
  • 32

When you are setting nextEvent, you can limit only events that are after today like so. This also limits the output to being the first result:

.startDate('>= ' ~ now).limit(1)

So the full code would be along the lines of:

{% set nextEvent = craft.entries.section('events').order('startDate').startDate('>= ' ~ now).limit(1) %}

{% for entry in nextEvent %}
    foo
{% endfor %}

I have assumed you have a section called 'Event's until we get some clarification as to what craft.events.events is.