2

I'm trying to pull entries from multiple sections for a list on a page, which works fine:

{% if section is not defined %}
    {% set section = 'events,checklists,opinionPieces,whitepapers' %}
{% endif %}

{% set params = {
    section: section
} %}

The problem I'm having is that the 'checklists' section is a structure with child entries allowed, and I only want the top level entries. I hoped I could get away with this:

{% if section is not defined %}
    {% set section = 'events,checklists,opinionPieces,whitepapers' %}
{% endif %}

{% set params = {
    section: section,
    level: 1
} %}

But that then only returns checklists and whitepapers, presumably because they are structures and the other two are channels.

Is there an easy way of getting this to work, or would I have to pull all entries separately into an array?

2

or would I have to pull all entries separately into an array?

This one.

100% untested, but something like this should work:

{% set ids = [] %}

{% set ids = ids|merge(craft.entries.section('events,opinionPieces,whitepapers').ids()) %}

{% set ids = ids|merge(craft.entries.section('checklists').level(1).ids()) %}

{% set entries = craft.entries.id(ids).find() %}

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.