As our template is a bunch of includes, here is the standalone filter with checkboxes ![]()
This should create the filters with the correct URL .
Have a go!
{# Get current countries for list and filter #}
{% if request.query_dict != '' %} {# if there is a paramater/filter selected #}
{% set categories = [] %} {# create array to collect category #}
{% for item in request.query|split('&') %} {# split paramaters together with values #}
{% set currect_categories = item|split('=') %} {# split value from paramater #}
{% if currect_categories[0] == 'category' %} {# check if it's a country #}
{% do categories.append(currect_categories[1]) %} {# add to selected countries array #}
{% endif %}
{% endfor %}
{% endif %}
{% set cat_label = module.cat_label || 'Categories' %}
{% set show_all = module.show_all || 'Show all' %}
<div class="blog-listing__sidebar">
{% set blog_topics = blog_topics(group.id, 250)|sort(False, False, 'name') %}
<form class="filters" id="categories" method="get" action="{{ group.absolute_url|replace('http', 'https') }}/all">
<div class="filter">
<div class="filter__label">
<label>{{ cat_label }}</label>
</div>
<div class="filter__list-wrapper">
<div class="filter__list">
{% for blog_topic in blog_topics %}
<div class="filter-item {% if topic == blog_topic.slug || blog_topic.slug in categories %}filter-item--active{% endif %}">
<input class="filter-item__input" type="checkbox" {% if topic == blog_topic.slug || blog_topic.slug in categories %}checked{% endif %}{# {% if request.query_dict.cat == blog_topic.slug %}checked{% endif %} #} name="category" value="{{ blog_topic.slug }}" id="checkbox-{{ blog_topic.slug }}" form="categories" onclick="this.form.submit()">
<label class="filter-item__label" for="checkbox-{{ blog_topic.slug }}">{{ blog_topic }}</label>
</div>
{% endfor %}
</div>
</div>
</div>
</form>
</div>