# hubDB show-all filter

**URL:** <https://community.hubspot.com/t/hubdb-show-all-filter/62924>\
**Category:** CMS Development\
**Tags:** design-manager, hubdb\
**Created:** [August 12, 2022, 5:11pm UTC](https://community.hubspot.com/t/hubdb-show-all-filter/62924 "2022-08-12T17:11:17Z")\
**Posts on this page:** 6\
**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:** [August 12, 2022, 5:11pm UTC](https://community.hubspot.com/t/hubdb-show-all-filter/62924/1 "2022-08-12T17:11:17Z")

</div>

Hi everyone,  
I’m trying to add a filter on a resource library that displays all assets, 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;
 }
 else {
 document.location.href='{{module.resources_page_link.url.href}}';
 } 
 });
 </script>

```

with the else{} it still adds ?topic=show-all to the URL path.

Any help is appreciated!

-Jonathan

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [August 12, 2022, 6:08pm UTC](https://community.hubspot.com/t/hubdb-show-all-filter/62924/2 "2022-08-12T18:08:54Z")

</div>

@jpineda91 The value when selecting Show All isn’t empty, it’s “show-all”, so either remove the value from the Show All option or change your if statement to:

```lia-code-sample
if(topic && topic != 'show-all')) {
 document.location.href='{{module.resources_page_link.url.href}}?topic={{tag}}'+topic;
} else {
 document.location.href='{{module.resources_page_link.url.href}}';
} 

```

---

<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 12, 2022, 6:21pm UTC](https://community.hubspot.com/t/hubdb-show-all-filter/62924/3 "2022-08-12T18:21:00Z")

</div>

Hi @alyssamwilie  
Thank you so much for your reply!  
I tried updating the code with your suggestion, but when I click on the Show All option it reloads the page with the same path (?topic=…)

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [August 12, 2022, 6:23pm UTC](https://community.hubspot.com/t/hubdb-show-all-filter/62924/4 "2022-08-12T18:23:37Z")

</div>

@jpineda91 Do you have a public preview link I could look at to see what’s going on?

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [August 12, 2022, 6:40pm UTC](https://community.hubspot.com/t/hubdb-show-all-filter/62924/5 "2022-08-12T18:40:52Z")

</div>

@jpineda91 It looks like your _module.resources\_page\_link.url.href_ variable is returning blank. When document.location.href is set to blank it just refreshes the page.

 ![link-variable.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/e/c/ec483296d27c92a19fd3772c06d4d94936715a19.png)

If you’re just going to be staying on the same page then I don’t think a variable is necessary you could use the location object in javascript instead.

```lia-code-sample
jQuery('select[name="topic"]').on('change',function(){
 let topic = jQuery(this).val();
 let link = location.protocol + '//' + location.host + location.pathname;

 if(topic && topic != 'show-all')) {
 document.location.href = link + '?topic={{tag}}' + topic;
 } else {
 document.location.href = link;
 } 
});

```

---

<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 12, 2022, 6:49pm UTC](https://community.hubspot.com/t/hubdb-show-all-filter/62924/6 "2022-08-12T18:49:46Z")

</div>

@alyssamwilie  
Thank you so much! It worked 👍
