ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Only show upcomming entries with a custom date field

March 17, 2011 6:23am

Subscribe [3]
  • #1 / Mar 17, 2011 6:23am

    Jonas G

    61 posts

    Hi. I’m very new to EE so excuse me if this is trivial.

    I have an “events” channel which has 2 custom fields: from_date and to_date. I would like to list all entries in this channel, where the from_date is in the future. I have been looking at “show_future_entries” but I can’t seem to specify which date field it should use for reference.

    Are there an even easier solution for what’s i’m trying to do?

    Jonas

  • #2 / Mar 17, 2011 3:28pm

    Sue Crocker

    26054 posts

    Hi, Jonas. There are two ways to approach this. One way is to use the built in entry_date to be your from_date. That way you just have to use show_future_entries.

    The other way is to sort by your custom date field.

    See: http://ellislab.com/expressionengine/user-guide/modules/channel/parameters.html#par_orderby

    You’d use

    orderby="from_date"

    It’ll default to sort=“desc” if you don’t specify a sort order. Does that help?

  • #3 / Mar 18, 2011 8:37am

    Jonas G

    61 posts

    Thanks for the reply. I am already using orderby=“from_date” and sort=“asc” but the problem with that is, that it also lists past events. An example:

    I have the following events

    March 1st event
    April 1st event
    May 1st event

    I need to render a list with the future events:

    April 1st event
    May 1st event

    If I just use orderby and sort I will get the complete list - without past events filtered out:

    March 1st event
    April 1st event
    May 1st event
  • #4 / Mar 18, 2011 3:56pm

    Sue Crocker

    26054 posts

    So you aren’t expiring them when they end? You may want to set an expiration date. Does that help?

  • #5 / Mar 19, 2011 8:40am

    Jonas G

    61 posts

    I don’t really want to expire the events after they end as I still want to be able to visit the page and see it in another calendar.

  • #6 / Mar 21, 2011 4:02am

    John Henry Donovan

    12339 posts

    Jonas,

    Take a look at the start_on= parameter and its common uses. The example used is exactly what you need

    {exp:channel:entries channel="{my_weblog}" sort="desc" start_on="{current_time format='%Y-%m-%d %H:%i'}" show_future_entries="yes"}
  • #7 / Mar 21, 2011 4:46am

    Jonas G

    61 posts

    John is it possible to use your example with a date custom_field. My TO and FROM dates are being set in custom fields (to_date, from_date) and it looks like your example uses the date from entry_date

  • #8 / Mar 21, 2011 5:20pm

    Sue Crocker

    26054 posts

    Give it a try, it worked for me in a very rudimentary test.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases