<p>A better/easier route would be to just create custom Date/Time fields that store the event start and end dates. Entries’ Post and Expiry dates are meant to define when the entry should be visible on the front end; they are not meant to be part of the entry’s content.</p>

CC BY-SA 3.0
2017-03-23T18:51:16.823Z
Then how would you create a typical listing page that shows only upcoming events? Using search would seem the obvious approach, but that would require some logic - e.g. customDateField:'>now' - which does not seem to be supported by search parameters.
Roi Agneta
CC BY-SA 3.0
2017-03-23T22:55:08.163Z
You can do `.myDateField('>='~now)`
Brandon Kelly
CC BY-SA 3.0
2017-03-23T23:18:42.087Z
That works - thanks! However, I am bit confused, since I did not realize you can use a custom field as a craft.entry parameter and I do not see it anywhere in the docs. What am I missing?
Roi Agneta
CC BY-SA 3.0
2017-03-24T04:21:23.063Z
I guess it’s never documented explicitly, but many of the examples on https://craftcms.com/docs/templating/elementcriteriamodel include custom field handles as criteria params.
Brandon Kelly
CC BY-SA 3.0
2017-03-24T21:10:43.313Z
OK, thanks, guess I should have read that more carefully. Given how powerful that feature is, might be good to have it listed as a parameter in the applicable Querying Elements section.
Roi Agneta
CC BY-SA 3.0
2017-03-16T17:39:28.150Z
2017-03-16T17:39:28.150Z
Brandon Kelly
<p>As Brandon wrote, I just created a date field {{eventDate}} and then just search based on if the eventDate was later than NOW in the section named Events.</p>

<pre><code>{% set events = craft.entries.find({section:'events', eventDate : "&gt;= " ~ now.w3cDate() , order:'eventDate'}) %}
    {% for entry in events %}
        &lt;p&gt;{{ entry.eventDate.format('D j M') }}, {{ entry.eventName }}&lt;/p&gt;
    {% endfor %}
</code></pre>

<p>or use this format:</p>

<pre><code>{% set events = craft.entries.find({
    section: 'events',
    eventDate: '&gt;= ' ~ now.w3cDate(),
    order: 'eventDate asc'
}) %}
    {% for entry in events %}
        &lt;p&gt;{{ entry.eventDate.format('D j M') }}, {{ entry.eventName }}&lt;/p&gt;
    {% endfor %}
</code></pre>

CC BY-SA 3.0
2017-04-01T14:18:34.473Z
2017-04-01T14:18:34.473Z
Paul Frost
<p><strong>STEP ONE:</strong><br>
Create an "Events" section in Craft and uncheck "Entries in this section have their own URLS".</p>

<p><img src="https://i.sstatic.net/mYFFP.png" alt="enter image description here"></p>

<hr>

<p><strong>STEP TWO:</strong><br>
Create your listing page and use ".status('pending')" to have CRAFT return only future dated entries. Also use ".order('postDate')" to have Craft order entries so that the next future dated entry is the first in the list:</p>

<pre><code>{% set entries = craft.entries.section("events").order('postDate').status('pending') %}
</code></pre>

<hr>

<p><strong>STEP THREE:</strong><br>
In the listing template, you need to manually build the URL to the event's detail page:</p>

<pre><code>&lt;a href="/events/{{ entry.slug }}"&gt;{{ entry.title }}&lt;/a&gt;
</code></pre>

<hr>

<p><strong>STEP FOUR:</strong><br>
Set up a custom Route to tell Craft which template to load for the URL pattern you're using in STEP THREE.
<img src="https://i.sstatic.net/6B4iQ.png" alt="enter image description here"></p>

<hr>

<p><strong>STEP FIVE:</strong><br>
Code your event's detail page template to grab the entry's slug from the URL and query the DB to get the right entry.</p>

<pre><code>{% set slug = craft.request.getSegment(2) %}
{% set entry = craft.entries.section("events").slug(slug).status('live', 'pending', 'expired').find()%}
{% for entry in entry %}
    &lt;h1&gt;{{ entry.title }}&lt;/h1&gt;
{% endfor %}
</code></pre>

<p><em>NOTE:</em> I've set the code sample in STEP FIVE to use .status('live', 'pending', 'expired') to show return these types of entries on my event detail page. You can use .status(null) to return ANY/ALL entries on the event detail page... or you can use .status('pending') if you only want future dated events to show and all others to return a 404. This is 100% up to you and based on your project requirements.</p>

CC BY-SA 3.0
2015-03-03T20:15:58.897Z
I was just about to answer you the same, Anna. But instead of setting the status to `null` or `'pending'` my suggestion would have been to use `'live', 'pending'`, which gives you current and future entries but exludes expired or disabled ones.
carlcs
CC BY-SA 3.0
2015-03-03T20:28:26.470Z
In my case, I want expired entries to show on the detail page but not showing disabled would be okay... would it be 'live', 'pending', 'expired" in that case?
Anna_MediaGirl
CC BY-SA 3.0
2015-03-03T20:31:33.427Z
Ah ok, then I'd use `status('live', 'pending', 'expired')`, so that you're still able to disable entries manually!
carlcs
CC BY-SA 3.0
2015-03-03T20:40:52.467Z
Perfect! I've edited STEP FIVE above to show that .status() is flexible. Thank you for the addition.
Anna_MediaGirl
CC BY-SA 3.0
2017-01-15T11:54:56.187Z
This seems annoyingly complicated for a fairly common use case.
kmgdev
CC BY-SA 3.0
2015-03-03T20:09:21.707Z
2015-03-03T20:51:26.187Z
2015-03-03T20:51:26.187Z
Anna_MediaGirl
<p>I'm struggling to set up a listing template and a detail template which will display "event" entries with post date set in the future. I keep getting a 404 error on the detail page. How do I set up Craft &amp; templates to show future dated entries on a listing and detail page?</p>

<templating><entries><datetime>
How do I set up event listing & detail pages with entry post dates that are in the future?
# How do I set up event listing & detail pages with entry post dates that are in the future?

(Asked by: username_0 on 2015-03-03)

I'm struggling to set up a listing template and a detail template which will display "event" entries with post date set in the future. I keep getting a 404 error on the detail page. How do I set up Craft & templates to show future dated entries on a listing and detail page?

**Tags:** templating, entries, datetime

---

## 3 answers

### Answer by username_0 on 2015-03-03. Score: 13 | Accepted answer

STEP ONE:
Create an "Events" section in Craft and uncheck "Entries in this section have their own URLS".


STEP TWO:
Create your listing page and use ".status('pending')" to have CRAFT return only future dated entries. Also use ".order('postDate')" to have Craft order entries so that the next future dated entry is the first in the list:
{% set entries = craft.entries.section("events").order('postDate').status('pending') %}


STEP THREE:
In the listing template, you need to manually build the URL to the event's detail page:
{{ entry.title }}


STEP FOUR:
Set up a custom Route to tell Craft which template to load for the URL pattern you're using in STEP THREE.


STEP FIVE:
Code your event's detail page template to grab the entry's slug from the URL and query the DB to get the right entry.
{% set slug = craft.request.getSegment(2) %}
{% set entry = craft.entries.section("events").slug(slug).status('live', 'pending', 'expired').find()%}
{% for entry in entry %}
    {{ entry.title }}
{% endfor %}

NOTE: I've set the code sample in STEP FIVE to use .status('live', 'pending', 'expired') to show return these types of entries on my event detail page. You can use .status(null) to return ANY/ALL entries on the event detail page... or you can use .status('pending') if you only want future dated events to show and all others to return a 404. This is 100% up to you and based on your project requirements.

> **Comments:**
> **username_4**: I was just about to answer you the same, Anna. But instead of setting the status to `null` or `'pending'` my suggestion would have been to use `'live', 'pending'`, which gives you current and future entries but exludes expired or disabled ones.  
> **username_0**: In my case, I want expired entries to show on the detail page but not showing disabled would be okay... would it be 'live', 'pending', 'expired" in that case?  
> **username_4**: Ah ok, then I'd use `status('live', 'pending', 'expired')`, so that you're still able to disable entries manually!  
> **username_0**: Perfect! I've edited STEP FIVE above to show that .status() is flexible. Thank you for the addition.  
> **username_5**: This seems annoyingly complicated for a fairly common use case.  

---

### Answer by username_1 on 2017-03-16. Score: 9

A better/easier route would be to just create custom Date/Time fields that store the event start and end dates. Entries’ Post and Expiry dates are meant to define when the entry should be visible on the front end; they are not meant to be part of the entry’s content.

> **Comments:**
> **username_2**: Then how would you create a typical listing page that shows only upcoming events? Using search would seem the obvious approach, but that would require some logic - e.g. customDateField:'>now' - which does not seem to be supported by search parameters.  
> **username_1**: You can do `.myDateField('>='~now)`  
> **username_2**: That works - thanks! However, I am bit confused, since I did not realize you can use a custom field as a craft.entry parameter and I do not see it anywhere in the docs. What am I missing?  
> **username_1**: I guess it’s never documented explicitly, but many of the examples on https://craftcms.com/docs/templating/elementcriteriamodel include custom field handles as criteria params.  
> **username_2**: OK, thanks, guess I should have read that more carefully. Given how powerful that feature is, might be good to have it listed as a parameter in the applicable Querying Elements section.  

---

### Answer by username_3 on 2017-04-01. Score: 4

As Brandon wrote, I just created a date field {{eventDate}} and then just search based on if the eventDate was later than NOW in the section named Events.
{% set events = craft.entries.find({section:'events', eventDate : ">= " ~ now.w3cDate() , order:'eventDate'}) %}
    {% for entry in events %}
        {{ entry.eventDate.format('D j M') }}, {{ entry.eventName }}
    {% endfor %}

or use this format:
{% set events = craft.entries.find({
    section: 'events',
    eventDate: '>= ' ~ now.w3cDate(),
    order: 'eventDate asc'
}) %}
    {% for entry in events %}
        {{ entry.eventDate.format('D j M') }}, {{ entry.eventName }}
    {% endfor %}


---

