1

I am using ExpressionEngine 2.5.2 and am unable to get my entries to sort by a custom date field. I have two sites through the Multisite Manager that I am pulling entries from. On both sites, the custom date field short name is the same - "event_date". Here's the code:

{exp:channel:entries  site="site1|site2" channel="events" orderby="event_date" sort="asc" status="next event|open"  limit="7"}
<li>
    <span class="event-name"><a href="#">{title}</a></span>
    <span class="date">{event_date format="%d %M %Y"}</span>
</li>
{/exp:channel:entries}

Here is the result in the browser:


Berlin 2013 ... 05 Mar 2013

Tokyo 2013 ... 13 Feb 2013

London 2013 ... 17 Apr 2013

Los Angeles 2013 ... 16 May 2013


Berlin is a part of Site2, and its status is "Next Event". Los Angeles, London, and Tokyo are a part of Site1, and their statuses are all set to "open". Anyone know what's wrong?

3
  • should you be using sort="asc" if you're also using orderby="event_date"?
    – magicspon
    Feb 8 '13 at 17:19
  • if i remove sort="asc", it doesn't change anything. if i change it to sort="desc", it doesn't solve my problem, just flips the incorrectly ordered items. Feb 8 '13 at 17:22
  • hmmm.. just a thought!
    – magicspon
    Feb 8 '13 at 17:23
1

You need to specify the field for each site individually:

orderby="site1_shortname:event_date|site2_shortname:event_date" sort="asc|asc"

What's happening right now is that it's matching the field name event_date to site 1 and ordering by that field for site 1, but using the default orderby (entry_date) for site 2.

(Docs.)

However, thinking about this further, this is actually expected behaviour. When specifying multiple orderby fields, it's sequential. So first you're ordering by field_id_X (whatever event_date is in site1). Well, site 2's entries are 0 in that field, so they come first.

You'd have to use a common field, like entry_date, to order entries from both sites sequentially together. (Check out EEvent Helper, which allows you to clone a custom date field to the Entry Date, among other things.)

9
  • hmmm still didn't work. rendering the same results as listed above in my question. Feb 8 '13 at 17:29
  • You're using the correct short name for each site, yes? (Sorry, have to ask!) Feb 8 '13 at 17:36
  • no problem. here's the actual EE entries call with the real site names included: {exp:channel:entries site="default_site|characterized" channel="events" orderby="default_site:event_date|characterized:event_date" sort="asc|asc" status="next event|open" limit="7"} Feb 8 '13 at 17:38
  • See update to my answer. Feb 8 '13 at 19:16
  • hi Derek - i was working on another project for a little while, now I'm back to this issue. It sounds like eevent helper is what i need. From what I understand, It is a field type and an extension, correct? I installed it by placing it in my third_party folder, and I see it as an option for a field type. However I do not see it on my entry page as an extension so that I can edit my dates under the date tab. Am I missing something? Mar 18 '13 at 17:11

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.