# HubDb filter show-all

**URL:** <https://community.hubspot.com/t/hubdb-filter-show-all/61576>\
**Category:** CMS Development\
**Tags:** hubdb\
**Created:** [July 23, 2022, 1:39am UTC](https://community.hubspot.com/t/hubdb-filter-show-all/61576 "2022-07-23T01:39:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpineda91](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@jpineda91](https://community.hubspot.com/u/jpineda91)\
**Post date:** [July 23, 2022, 1:39am UTC](https://community.hubspot.com/t/hubdb-filter-show-all/61576/1 "2022-07-23T01:39:00Z")

</div>

Hello everyone,  
I have a resource page with a filter by content\_type, everything is working properly, but I need to add a filter to show-all. Here is my code:

```lia-code-sample
<select name="topic">
 <option value="">View Resources By Type</option>
 <option value="show-all">Show All</option>

 {% set content_type_array = [] %}
 {% for content_type in resource_content_type|map(attribute='content_type') %}
 {% unless content_type.name in content_type_array %}
 {% unless content_type.name == null %}
 {% do content_type_array.append(content_type.name) %}
 {% endunless %}
 {% endunless %}
 {% endfor %}
 {% for item in content_type_array %}
 <option {% if request.query_dict.topic == item %} selected{% endif %}>{{ item }}</option>
 {% endfor %}
 </select>
 <script>
 jQuery('select[name="topic"]').on('change',function(){
 let topic = jQuery(this).val();
 if(topic !='') {
 document.location.href='{{module.resources_page_link.url.href}}?topic={{tag}}'+topic;
 } 
 });
 </script>

```

I’m not sure how to display all the resources with a show-all filter, any help is appreciated.  
thanks in advance,

Jonathan

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [July 25, 2022, 4:12pm UTC](https://community.hubspot.com/t/hubdb-filter-show-all/61576/2 "2022-07-25T16:12:13Z")

</div>

Hi, @jpineda91! Hey @Anton @Oezcan can you lend some insight here on how @jpineda91 might approach this one?

Thank you! — Jaycee

---

<div class="post-metadata">

**Author:** ![Anton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/anton/32/103167_2.png) [@Anton](https://community.hubspot.com/u/Anton)\
**Post date:** [July 25, 2022, 11:21pm UTC](https://community.hubspot.com/t/hubdb-filter-show-all/61576/3 "2022-07-25T23:21:51Z")

</div>

Hi @jpineda91,

a really long time ago there was a so called “real estate” HubDB Tutorial at [developers.hubspot.com](http://developers.hubspot.com) but unfortunately it’s no longer available. [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) - any chance it will be available again?

Long story short - the idea was to work with queryparams. Kinda the same thing you’re doing @jpineda91,

To get the “show all” option I’d say you could do it like this

```lia-code-sample
 <script>
 jQuery('select[name="topic"]').on('change',function(){
 let topic = jQuery(this).val();
 if(topic !='') {
 document.location.href='{{module.resources_page_link.url.href}}?topic={{tag}}'+topic;
 } else {
 document.location.href='{{module.resources_page_link.url.href}}';
} 
 });
 </script>

```

Also here’s the logic original code from the tutorial

```lia-code-sample
<form id="hubdb-filter" method="get">
 <div> 
 <select name="my-hubdb-column" form="form_id" id="my-hubdb-column" onChange="this.form.submit()">
 <option value="show-all">All Categories</option>
 {% set types = hubdb_table_column(XXXXXXX,"my-custom-hubdb-column").options %}
 {% for choice in types %}
 {% set type_list = type_list~choice.id|list %}
 {% if choice.id == request.query_dict.my-custom-hubdb-column %}
 <option selected="selected" value="{{ choice.id }}">{{ choice.name }}</option>
 {% else %}
 <option value="{{ choice.id }}">{{ choice.name }}</option>
 {% endif %}
 {% endfor %}
 </select>
				<input type="submit">
 </div>
</form>

<!-- sets the different query parameters using submitted input for hubdb query -->

{% set queryparam = "" %}
{% if request.query_dict.my-hubdb-column in ["1", "2", "3"] %}
 {% set queryparam = queryparam ~ "&my-custom-hubdb-column__contains="~request.query_dict.my-hubdb-column|urlencode %} 
{% endif %}
{% if request.query_dict.my-hubdb-column == "show-all" %}
 {% set queryparam = queryparam %}
{% endif %}

```

hope this helps,

best,

Anton

---

<div class="post-metadata">

**Author:** ![jpineda91](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@jpineda91](https://community.hubspot.com/u/jpineda91)\
**Post date:** [July 29, 2022, 1:43pm UTC](https://community.hubspot.com/t/hubdb-filter-show-all/61576/4 "2022-07-29T13:43:34Z")

</div>

Hi @Anton, thank you so much for your reply!  
I tried the code but it is still adding the ?topic=show-all. Any help is appreciated.

```lia-code-sample
<select name="topic">
 <option value="">View Resources By Type</option>
 <option value="show-all">Show All</option>

 {% set content_type_array = [] %}
 {% for content_type in resource_content_type|map(attribute='content_type') %}
 {% unless content_type.name in content_type_array %}
 {% unless content_type.name == null %}
 {% do content_type_array.append(content_type.name) %}
 {% endunless %}
 {% endunless %}
 {% endfor %}
 {% for item in content_type_array %}
 <option {% if request.query_dict.topic == item %} selected{% endif %}>{{ item }}</option>
 {% endfor %}
 </select>
 <script>
 jQuery('select[name="topic"]').on('change',function(){
 let topic = jQuery(this).val();
 if(topic !='') {
 document.location.href='{{module.resources_page_link.url.href}}?topic={{tag}}'+topic;
 }
 else {
 document.location.href='{{module.resources_page_link.url.href}}';
 } 
 });
 </script>

```

---

<div class="post-metadata">

**Author:** ![jpineda91](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@jpineda91](https://community.hubspot.com/u/jpineda91)\
**Post date:** [August 10, 2022, 10:49pm UTC](https://community.hubspot.com/t/hubdb-filter-show-all/61576/5 "2022-08-10T22:49:33Z")

</div>

\*\*\*Update\*\*\*  
@alyssamwilie Helped me solve this in another [post](https://community.hubspot.com/t5/CMS-Development/hubDB-show-all-filter/m-p/679951#M30010)

```lia-code-sample
<select name="topic">
 <option value="">View Resources By Type</option>
 <option value="">Show All</option>
 {% set content_type_array = [] %}
 {% for content_type in resource_content_type|map(attribute='content_type') %}
 {% unless content_type.name in content_type_array %}
 {% unless content_type.name == null %}
 {% do content_type_array.append(content_type.name) %}
 {% endunless %}
 {% endunless %}
 {% endfor %}
 {% for item in content_type_array %}
 <option {% if request.query_dict.topic == item %} selected{% endif %}>{{ item }}</option>
 {% endfor %}
 </select>
 <script>
 jQuery('select[name="topic"]').on('change',function(){
 let topic = jQuery(this).val();
 let link = location.protocol + '//' + location.host + location.pathname;

 if(topic !='') {
 document.location.href = link + '?topic={{tag}}' + topic;
 } else {
 document.location.href = link;
 } 
 });
 </script>

```
