Hi all, I have set up a filter that pulls data from a Hubdb with a 'select' column type. {% if request.query_dict.type in ["1", "2", "3", "4","5", "6", "7", "8", "9", "10"] %}
My question is how do I do a similar thing with a 'multiselect' column type? (edited)
Nov 27, 20187:39 AM - edited Nov 27, 20187:41 AM
Top Contributor
Filtering HubDB Multiselect
Hi @roisinkirby I need to replace the second filter query so that the second filter dropdown only returns Hubdb entries that contain that Hubdb multi-select tag. Here is my current code:
<form id="form_id" method="get">
<div>
<h4>Filter by resource type: </h4>
<select name="type" form="form_id" onChange="this.form.submit()">
<option value="show-all">Show All</option>
{% set types = hubdb_table_column(848813, "resource_type").options %}
{% for choice in types %}
{% set type_list = type_list~choice.id|list%}
{% if choice.id == request.query_dict.type%}
<option selected="selected" value="{{ choice.id }}" onclick="resourceFilter()">{{ choice.name }}</option>
{% else %}
<option value="{{ choice.id }}">{{ choice.name }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div>
<h4>Filter by topic area: </h4>
<select name="area" form="form_id" onChange="this.form.submit()">
<option value="show-all">Show All</option>
{% set areas = hubdb_table_column(848813, "focus_area").options %}
{% for choice in areas %}
{% set area_list = area_list~choice.id|list%}
{% if choice.id == request.query_dict.area%}
<option selected="selected" value="{{ choice.id }}" onclick="resourceFilter()">{{ choice.name }}</option>
{% else %}
<option value="{{ choice.id }}">{{ choice.name }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</form>
</div>
{% set queryparam = "&orderBy=resource_order"~"&resource_order__gt=0" %}
{% if request.query_dict.type in ["1", "2", "3", "4","5", "6", "7", "8", "9", "10"] %}
{% set queryparam = queryparam ~ "&resource_type="~request.query_dict.type|urlencode %}
{% endif %}
{% if request.query_dict.type == "show-all" %}
{% set queryparam = queryparam %}
{% endif %}
<!-- Multi-select hubdb query -->
{% set areaquery = "&orderBy=resource_order"~"&resource_order__gt=0" %}
{% if request.query_dict.area in ["1", "2", "3", "4","5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"] %}
{% set areaquery = areaquery ~ "&focus_area="~request.query_dict.area|urlencode %}
{% endif %}
{% if request.query_dict.area == "show-all" %}
{% set areaquery = areaquery %}
{% endif %}