2

I have a channel with a custom field (type "date") called start. Now I want a list of all channel entries where the start date is today or in the future. So according the EE documentary I'm using the following:

{exp:channel:entries channel="calendar" dynamic="no" orderby="start" sort="asc" start_on="{current_time format='%Y-%m-%d'}" show_future_entries="yes"}
  {title}
{/exp:channel:entries}

But now I only get a list of all entries with the start date = today. All future entries are not shown. It is also not clear for me what field start_on is looking at.

How do I get this working?

5

The start_on parameter uses the entry_date, not the custom date field you defined. To target the custom field, use the search: parameter. Also, you need to know how EE stores its date fields: as a Unix timestamp. Which just is a large number.

With EE 2.7+, you can use Numeric matching, so you could use that too.

search:my_custom_date_field=">={current_time}"

The {current_time} variable without a format parameter will output the Unix timestamp for right now, so using that as input for the search:-parameter should give you the desired results.

  • Thank you very much, that's exactly the answer I was looking for! Great and many thanks! – Timo002 Oct 10 '13 at 12:07
1

Low has pointed out the why of your dilemma. There is one other solution you can consider; Solspace's date field filter, which allows you to remap the default date ordering functionality (which as Low points out is tied to the entry_date). This way, you can apply the "proper" ordering parameters for the entries loop, making your custom field the date to use. So then you wind up with something like:

{exp:channel:entries
date_field="your_custom_date_field"
date_field_start="2012-12-02 12:01 AM"
date_field_stop="2012-12-04 11:59 PM"
orderby="your_custom_date_field"
sort="asc"
}
    <li><b>{title}</b> - {date_field format="%F %j, %Y at %g:%i %a"}</li>
    {if no_results}
        <li>No results found within this time range.</li>
    {/if}
{/exp:channel:entries}

And like you attempted to do in your entries loop before, you can then replace your date_field_start param value with the current time variable.

Low would certainly know better than I how this approach would compare efficiency-wise relative to using the search parameter. I've used this add-on, which is now free, and it worked great for me. Just thought I would throw another option out there even though Low's suggestion solved it for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.