Hey there.
I’m looking for a way to sort entries of a structure field by one of its field values (which is a date):
events:
label: Calendar
type: structure
entry: >
<strong>{{summary}}</strong><br>
{{description}}<br>
fields:
summary:
label: Summary
type: text
description:
label: Description
type: textarea
begin_date:
label: Start
type: date
end_date:
label: End
type: date
and my template looks like this:
<?php $events = $page->events($own = true, $allies = array('children' => true, 'siblings' => true)); ?>
<?php foreach ($events as $key => $event) : ?>
<?php snippet('event-teaser', array('event' => $event)); ?>
<?php endforeach ?>
Now I tried different things, like appending ->sortby(begin_date(), 'desc')
to the $events
definition, but nothing seems to work really … I replaced begin_date with different toStructure()
calls and stuff like this to access the begin_date field, but I am stuck really …