I have a channel to manage events and I'm facing a problem when I want to implement some common operations like displaying past events. If I want to see the current and future events I assumed I can get it in the following way:
{exp:channel:entries channel="events" show_future_entries="yes" show_expired="no" orderby="{date}" sort="asc" dynamic="no" start_on=""}
where $entry_date is in the format YYYY-MM-DD HH:MM (ex: 2011-08-02 11:00)
It should display the events in this order:
2012-08-02 11:00
2012-09-02 11:00
2012-10-02 11:00
2012-11-02 11:00
But it's displaying them without including the event at 2012-08-02 11:00 (seems the comparison EE does is >, not >=)
And also the past events (which are marked like expired already)I organized and display them by year:
{exp:channel:entries channel="events" show_future_entries="no" show_expired="yes" orderby="{date}" sort="desc" dynamic="no" year="" start_on=""}
assuming my past events are:
2011-08-02 11:00
2011-09-02 11:00
2011-10-02 11:00
2011-11-02 11:00
and $entry_date = 2011-10-02 11:00
It should display something like this:
2011-10-02 11:00
2011-09-02 11:00
2011-08-02 11:00
and its displaying it in a incorrect order.
In fact the problems are:
Can somebody tell me if there is something wrong with my code?
I'm using EE 2.4.0 and php is enable at the input in the templates where I try to do those operations.
A few things I see here.
orderby="{date}"
should actually be orderby="date"
(or it can be omitted entirely, since date/entry_date is the default orderby).
Your issue with the upcoming events may be the way you're generating your $entry_date
variable. Can you tell me how that's being created exactly? Are you echoing it out somewhere to make sure it is in fact what you think it is? You could be encountering localization differences between EE and your server. If you indeed have an entry with the exact same entry date as what you out in start_on
, it should appear. Try putting the date in start_on
manually to troubleshoot.
For your past events, you should be using stop_before
, not start_on
. These two parameters do not pay heed to your sort
parameter - they are always based on chronology.