collection count with filters inside if statement

I want to show a filtered subset of a collection but only if there are items in the filtered set. Something like this:

{{ if {collection:count in="fleet" aircraft_type:is="jet"} > 0 }}
    <h2>Jets</h2>
    <loop the filtered collection and show the jets>
{{ /if }}

but that throws a Statamic\Exceptions\CollectionNotFoundException error: Collection [__cond_callbacks_<long alphanumeric string>] not found

If I remove the filter:

{{ if {collection:count in="fleet"} > 0 }}

this works just fine, but is obviously not what I need.

If I just echo the count with the filter:

{{ collection:count in="fleet" aircraft_type:is="jet" }}

that also works just fine. Is it possible to only show a page section if there are items within a filtered collection set? I feel like this is rather elementary and I'm just missing something. Am I going about this entirely incorrectly? Is there a better way?

Thank you for your assistance.

Answered by Byron Fitzgerald!
>>>>>>> Answered <<<<<<<
2 Replies
2 Followers