How to filter selected value using setcontent?

140 Views Asked by At

I am working on a Bolt template which returns different information about the listing and I have problems when trying to use setcontent filtering. I use URL queries to toggle the search, like so:

{% if app.request.query.get('onlyPaid') == 'true' %}
    {% setcontent records = 'internships' where { is_paid: 1} limit 6 %}
{% endif %}

This filter works great because i have an is_paid field described in my contenttypes.yml

The question is, how do I apply the similar filter to the selected value of 'select' field?

city:
            type: select
            label: City
            values: regions/{title}
            sort: title
            autocomplete: true
            required: true
1

There are 1 best solutions below

0
Joseph On

However this is not a perfect/straight solution, currently works by using "%like%" operator, as you can see below:

{% setcontent building_items = 'buildings' where { 'building_type': '%public%' } %}

The string 'public' is the selected value of the SELECT's field.

The definition of the field in the contenttypes.yaml is this:

        building_type:
            type: select
            values:
                residential: Residential
                public: Public