I think I’ve discovered a bug with EE2 and the orderby parameter. When I use the following:
{exp:channel:entries channel="sessions" dynamic="off" orderby="entry_date|expiration_date" sort="asc|asc" show_expired="yes" show_future_entries="yes" start_on="2011-11-09 1:00" stop_before="2011-11-09 23:00"}and I have output profiler turned on so I can see the SQL queries being run, I can see that it ignores expiration_date in the order by clause in the SQL query. If I change the above to this:
{exp:channel:entries channel="sessions" dynamic="off" orderby="expiration_date|entry_date" sort="asc|asc" show_expired="yes" show_future_entries="yes" start_on="2011-11-09 1:00" stop_before="2011-11-09 23:00"}(where expiration_date is the first field to be sorted) I can see expiration_date is included in the SQL query as a field to order by.
I’d rather not have to use exp:query just to get around this, but I need the entries sorted on both entry and expiration. Further complicating this is the fact that EE artificially changes the entry_date and expiration_date by a few seconds so even though two entries have the same date entered in the control panel, they won’t be viewed as having the same entry_date in the SQL query due to the timestamps being off.