I have a query that loads a set of movies
, and eager-loads corresponding shows
, which are related elements. For now, the movies are sorted by startingDate
, which is a custom field in the movie
entry:
{% set currentMovies = craft.entries({
section: 'movies',
type: 'movie',
order: 'startingDate asc',
limit: null,
with: [
'shows',
'poster',
'stills'
]
})
%}
What I actually want is to sort the movies by whichever film has the first upcoming screening. That basically means I would like to order the set by something to the effect of order: shows.showTime
or order: shows[0].showTime
, but that doesn't seem to work.
Is there a way to order by a field on a related entry, or is that variable simply not yet accessible at the point of ordering?
I tried to eager-load the shows.showtime
field, but realised that doesn't work either, as eager-loading only makes sense for relations, not fields themselves.