You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no doc about how to filter collection entries based on a mapped taxonomy.
There is a quick mention to the existence of two methods "whereTaxonomy" and "whereTaxonomyIn" but no examples of how to use it. IMHO, we should mention them in the https://statamic.dev/repositories/entry-repository#querying doc page, with some examples.
It took me a while to understand we should follow this format :
Entry::query()
->where('collection', 'blog')
->whereTaxonomy('tag::holidays') //here "tag" is the taxonomy id, and "holidays" the term id
->get();
Entry::query()
->where('collection', 'blog')
->whereTaxonomyIn(["tag::holidays","tag::news"]) // == entries having either a "holidays" tag OR a "news" tag
->get();
It could also be great to mention that only works if the "taxonomy id" (ie "tag" in the above example), match a field "named" tag in the collection blueprint. If it does not, the "whereJsonContains" workaround could also be documented : statamic/cms#4098 (comment)
The text was updated successfully, but these errors were encountered:
There is no doc about how to filter collection entries based on a mapped taxonomy.
There is a quick mention to the existence of two methods "whereTaxonomy" and "whereTaxonomyIn" but no examples of how to use it. IMHO, we should mention them in the https://statamic.dev/repositories/entry-repository#querying doc page, with some examples.
It took me a while to understand we should follow this format :
It could also be great to mention that only works if the "taxonomy id" (ie "tag" in the above example), match a field "named" tag in the collection blueprint. If it does not, the "whereJsonContains" workaround could also be documented : statamic/cms#4098 (comment)
The text was updated successfully, but these errors were encountered: