We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Date span for an Event

Bruno Pinto October 13, 2014 by Bruno Pinto

Hey all, I've got a little problem here and I hope you can help me.

I have two date fields in a fieldset: "date" and "end_date". The last one added by me.

What I want to achieve is:
I want to sort all entries with direction asc: sort_dir="asc"
I want to sort by end_date: sort_by="end_date"
and I want to show only 3(!) future entries: show_future="true" and limit="3"

The problem is that I also want to show past entries, since an Event can have a start date in the past and an end date in the future.

Here's what I have so far:

{{ entries:listing folder="{fold}" limit="3" show_future="true" sort_dir="asc" sort_by="end_date" }}
  {{ if !no_results }}
    {{ if first }}
    <div class="events">
      <h2 class="title">In the Agenda</h2>
      <ul class="events-list">
    {{ endif }}
    {{ if end_date|in_future }}
      {{ theme:partial src="{{ events }}/_events_list_markup_front" url="{{ url }}" use_context="true" }}
    {{ endif }}
    {{ if last }}
        <a href="{{ events }}">view all events</a>
    {{ endif }}
  {{ endif }}
{{ /entries:listing }}

Since my condition is only verified in the middle of the code:

{{ if end_date|in_future }}

I can't limit the entries' listing. The ideal scenario would be to list all of the entries with end_date|in_future sorted by dir asc.

Hope I made myself clear.
Kind regards,

Answered by Bruno Pinto!
>>>>>>> Answered <<<<<<<
1 Reply
1 Follower