Hi all, I am trying to update the code on our site so that it only shows case studies from our resource HubDb. At the minute everything is showing and can be filtered on the site Channel Marketing Resources | 360insights. I want to have a seperate resource area on another page that only displays case studies.
In the database the column is called ‘type’ and is a multi-select where ‘Case Studies’ is one of the options. I have cloned the original resource module code that we use and will remove the filters on the left. What do I need to change on this new module in orded for only case studes to be displayed? Thanks
<div class="resource-grid">
{# Filters #}
<div class="resource-filters">
<form>
<div class="resource-filters__search">
<input type="text" placeholder="Search" onkeypress="return event.keyCode != 13;">
</div>
<div class="resource-filters__filter">
<div class="resource-filters__filter-group mb-md">
<h2 class="h4">Browse by Topic</h2>
{% set resources = hubdb_table_rows(module.hubdb_id) %}
{% set topics = hubdb_table_column(module.hubdb_id, "topic").options %}
{% for topic in topics %}
<label><input type="checkbox" value="topic-{{ topic.name|lower|replace(" ", "-")|replace("&-", "")|replace(",", "") }}" {% if request.query_dict.topic == topic.name|lower|replace(" ", "-")|replace("&-", "")|replace(",", "") %}checked{% endif %} />{{ topic.name }}</label>
{% endfor %}
</div>
<div class="resource-filters__filter-group mb-md">
<h2 class="h4">Browse by Type</h2>
{% set resources = hubdb_table_rows(module.hubdb_id) %}
{% set types = hubdb_table_column(module.hubdb_id, "type").options %}
{% for type in types %}
<label><input type="checkbox" value="type-{{ type.name|lower|replace(" ", "-")|replace("&-", "")|replace(",", "") }}" {% if request.query_dict.type == type.name|lower|replace(" ", "-")|replace("&-", "")|replace(",", "") %}checked{% endif %} />{{ type.name }}</label>
{% endfor %}
</div>
<div class="resource-filters__filter-group ">
<h2 class="h4">Browse by Featured Topic </h2>
{% set resources = hubdb_table_rows(module.hubdb_id) %}
{% set types = hubdb_table_column(module.hubdb_id, "featured_resource").options %}
{% for type in types %}
<label><input type="checkbox" value="featured-{{ type.name|lower|replace(" ", "-")|replace("&-", "")|replace(",", "") }}" {% if request.query_dict.featured == type.name|lower|replace(" ", "-")|replace("&-", "")|replace(",", "") %}checked{% endif %} />{{ type.name }}</label>
{% endfor %}
</div>
</div>
</form>
</div>
{# Results #}
<div class="resource-items">
{% set queryparam = "orderBy=order&inactive=false" %}
{#% if request.query_dict.topic %}
{% set queryparam = queryparam ~ "topic="~request.query_dict.topic|urlencode %}
{% endif %}
{% if request.query_dict.type %}
{% set queryparam = queryparam ~ "&resource_type="~request.query_dict.type|urlencode %}
{% endif %#}
{% set resources = hubdb_table_rows(module.hubdb_id, queryparam) %}
{#<div class="resource-items__sizer"></div>#}
{% for resource in resources %}
<a href="{{ resource.link }}" {% if resource.open_link_in_new_tab %}target="_blank"{% endif %} class="resource-items__item {% for item in resource.featured_resource %}featured-{{ item.name|lower|replace(" ", "-")|replace("&-", "")|replace(",", "") }} {% endfor %} {% for item in resource.topic %}topic-{{ item.name|lower|replace(" ", "-")|replace("&-", "")|replace(",", "") }} {% endfor %} {% for item in resource.type %}type-{{ item.name|lower|replace(" ", "-")|replace("&-", "")|replace(",", "") }} {% endfor %}">
{% if resource.image %}
<img src="{{ resize_image_url(resource.image.url, 992, 620, 992) }}" loading="lazy" alt="{{ resource.name }}" class="resource-items__item-image">
{% endif %}
<div class="resource-items__item-details">
{% for item in resource.type %}
<p class="resource-items__type">{{ item.name }}</p>
{% endfor %}
<h3 class="resource-items__item-name">{{ resource.name }}</h3>
{% if resource.description %}
<p class="resource-items__item-description">{{ resource.description }}</p>
{% endif %}
<span class="button button--arrow button--notext">{{ resource.button_text if resource.button_text : 'Download' }}</span>
</div>
</a>
{% endfor %}
</div>
</div>
{{ require_js("https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js", "head") }}