1

I'm looping over my sections to produce a section filter group. But I want to exclude at least 2 of the sections.

I'd have thought I could do craft.sections.getAllSections('not 18') for example but it seems not.

What's best approach?

1

Here's how I've gone about that in the past.

Loop through all sections, and only if section.type is structure and doesn't have the handle 'pages' (skip that section, essentially);

{% for section in craft.sections.getAllSections() if section.type == 'structure' and section.handle != 'pages' %}
  What you want to do here... Print the content or whatnot.
{% endfor %}

And if you only want to get channels;

{% for section in craft.sections.getAllSections() if section.type == 'channel' %}
  What you want to do with the channels here...
{% endfor %}

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.