I have a list of events that may have 1 to multiple event dates. The dates and places of the events are stored in repeaters.
I would like to sort my eventlist by date:
Event 1
eventdate 1: 1.11.2013 15.00
eventdate 2: 15.11.2013 18.00
Event 2
eventdate 1: 5.11.2013 15.00
Event 3
eventdate 1: 14.11.2013 15.00
eventdate 2: 15.11.2013 18.00
eventdate 3: 16.11.2013 19.00
Event 4
eventdate 1: 17.11.2013 18.00
The repeater for the eventdetails has fields eventdetails.date and eventdetails.place. The event itself is stored with the template "event".
I have tried the following:
$events = $pages->find("template=event, sort=eventdetails.date");
This gives me an error: Column not found: 1054 Unknown column '_sort_eventdetails_date.date' in 'order clause'.
And this:
$events = $pages->find("template=event")->sort("eventdetails.date");
This gives me the correct order, but also an empty repeater item with empty eventdetails.date while looping the events:
foreach ($events as $e) {
foreach ($e->eventdetails as $d) {
$o .= strftime("%e.%m.%G %k:%M",strtotime($d->date)).", {$d->place}";
}
$o .= $e->title;
}
Output for event 1
1.11.2013 15:00, place1
15.11.2013 18:00, place2
1.01.1970 2:00,
Event 1
What is the correct way to sort by the date field in the repeater? Why do I get the empty repeater line (1.01.1970 2:00) in the second example?