1

I have a overview page that combines with two sections (documentation and galleries). Those two sections are attached to a parent Event. So you can select in the event entry a gallery or a documentation entry.

Question: How can i display those in order of the event's entry event day?

{% set entryGalleryIds         = craft.entries.section('gallery').ids() %}
{% set entryDocumentationIds   = craft.entries.section('documentation').ids() %}

{% set allEntryIds = entryGalleryIds|merge(entryDocumentationIds) %}

{% set allEntries = craft.entries.id(allEntryIds)|batch(3) %}

...

So i'm looking like something as:

{% set allEntries = craft.entries.id(allEntryIds).orderBy('events.eventDate desc')|batch(3) %}

Note: When i first query all the projects and then query the related galleries the sorting is gone, because of my id(allEntryIds) filter.

  • And you can't start at the events, looping through them (sorted) and output related galleries or documentations? – Urs Sep 22 '18 at 21:31
  • Hi Urs, this is an option, but a) it means entries without a parent won't be show (also not on the end) and b) it feels like bad programming do it this way. – Dave Driesmans Sep 23 '18 at 20:45
  • Well, if they don't have a parent, they don't have a date to sort by either. So you could output the "orphans" at the end craftcms.stackexchange.com/questions/10456/… – Urs Sep 24 '18 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.