New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Filtering collections by conditon1 OR condition2

Marius Haugen February 2, 2021 by Marius Haugen

Here's my case. I'm watching an employees page, and want to see projects that employee has been a part of. They can either be attached to a project as a project_leader (can only be 1 employee) or as a contributor (many employees)

  {{ collection:projects :project_leader:is="id" OR :people:contains="id" as="entries"  }}
            {{ if !no_results }}
                <div class="flex flex-wrap xl:-mx-12">
                    {{ entries }}
                        {{ partial:project-box margin="mb-8" }}
                    {{ /entries }}
            {{ /if }}
   {{ /collection:projects}}

Is this possible in antlers with the collection tag? Couldn't find anything about it.

So, if need to make a custom tag, I have another question. How do i query against an array?

            ->where('project_leader', $this->params->get('project_leader'))
            ->orWhere('contributors',  $this->params->get('contributor'));

Thanks, Marius.

Answered by Erin Dalzell!
>>>>>>> Answered <<<<<<<
1 Reply