如何使用setcontent筛选所选值



我正在开发一个Bolt模板,该模板返回有关列表的不同信息,在尝试使用setcontent筛选时遇到了问题。我使用URL查询来切换搜索,如下所示:

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

这个过滤器工作得很好,因为我在contenttypes.yml 中描述了一个is_paid字段

问题是,如何将类似的过滤器应用于"选择"字段的选定值?

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

然而,这不是一个完美/直接的解决方案,目前使用"%类似于%";操作员,如下所示:

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

字符串"public"是SELECT字段的选定值。

contenttypes.yaml中字段的定义如下:

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

最新更新