Query scopes ​
Overview ​
If you don't know what query scopes are, you can check Statamic's docs. This addon supports filtering using query scopes and contains a useful one you can use, called Multiselect
.
How to use ​
Utilizing a query scope is straightforward. Simply set the condition
property of any filter to query_scope
and the modifier
to the name of the scope you wish to use. For example:
{{ livewire:lf-checkbox-filter
blueprint="rooms.rooms"
field="room_amenities"
condition="query_scope"
modifier="you_query_scope_name"
}}
Presetting Multiple Query Scopes ​
In some cases, you may need to use multiple query scopes and preset values from each within your LivewireCollection
component.
To do this, use a pipe-separated list of query scopes, like so:
{{ livewire-collection:cars multiselect:brand="toyota" other_scope:type="SUV" query_scope="multiselect|other_scope" }}
Multiselect query scope ​
Deprecated
Starting with Statamic v5.64.0 you can use the overlaps
condition instead of this query scope. It will be removed from the addon in the future so you should avoid using it for new projects and opt for upgrading Statamic and using the overlaps
condition instead.
As emphasized in various sections of these documents, filtering entries using Statamic fields that support multiple values and are stored as arrays (such as checkboxes
or select
fields) doesn't work with the stock conditions, like is
.
In order to help you filter those entries, we ship the multiselect
query scope with this addon that magically works using whereJsonContains
. You're welcome.
{{ livewire:lf-checkbox-filter
blueprint="cars.cars"
field="car_brand"
condition="query_scope"
modifier="multiselect"
}}