I have a channel that is essentially a list of companies participating in an event.
Within that channel is a category group of sponsorship levels.
Companies that are sponsors are assigned a category. Companies that are just participants are not categorized.
I need to output a list of companies beginning with the categorized entries, and then the rest of the uncategorized entries.
The code I'm using below outputs the categorized list, but then I'm doing another loop for all companies (not just uncategorized).
Is there a better way, where I can exclude the categorized companies from the second loop (or include the uncategorized companies in the first loop?
{% set allCompanies = shuffle(craft.entries.section('companies').all()) %}
{% set sponsorCats = craft.categories().group('sponsors').relatedTo(allCompanies) %}
{# Loop the categories #}
{% for category in sponsorCats.all() %}
{# Get and loop through entries related to this cat #}
{% set sponsors = craft.entries.relatedTo(category) %}
{% for entry in sponsors.all() %}
entry details
{% endfor %}
{% endfor %}
{% for entry in allCompanies %}
entry details
{% endfor %}