<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: HubDB Filter and Results in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592685#M27771</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/71531"&gt;@AAM&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are you testing your page? To test a HubDB filter you need to publish the module onto a published page.&lt;/P&gt;
&lt;P&gt;Do you have a sample link for your module/page that you can share?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One tip:&lt;BR /&gt;You can replace &lt;CODE&gt;["1","2","3","4","5","6","7","8","9","10","11","12","13"]&lt;/CODE&gt; for &lt;CODE&gt;types|map('id')&lt;/CODE&gt;&amp;nbsp;to make it dynamic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HubSpot has a great tutorial about setting up filter for HubDB.&lt;/P&gt;
&lt;P&gt;I would recommend checking out this tutorial: &lt;A href="https://designers.hubspot.com/docs/tutorials/how-to-build-a-real-estate-listing-with-hubdb" target="_blank" rel="noopener"&gt;Let's Build A Real Estate Listing, using HubDB&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Mar 2022 08:45:49 GMT</pubDate>
    <dc:creator>Indra</dc:creator>
    <dc:date>2022-03-11T08:45:49Z</dc:date>
    <item>
      <title>HubDB Filter and Results</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592209#M27766</link>
      <description>&lt;P&gt;Hi. I'm new to the CMS and am trying to create a filtered list from a HubDB table. I've been successful in creating the dropdown for the filter, however when a selection is made, the body of the table stays the same and doesn't show the results from the filter. I'm pretty sure I'm missing code somewhere, but unsure exactly what. Can anyone help? Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;div&amp;gt;
    &amp;lt;form id="form_id" method="get"&amp;gt;
        &amp;lt;div&amp;gt;
            &amp;lt;h4&amp;gt;Publication Type: &amp;lt;/h4&amp;gt;
            &amp;lt;select name="pubtype" form="form_id" onChange="this.form.submit()"&amp;gt;
                &amp;lt;option value="show-all"&amp;gt;Show All&amp;lt;/option&amp;gt;
                {% set types = hubdb_table_column(5344131, "pubtype").options %} 
              {% for choice in types %} 
              {% set type_list = type_list~choice.id|list%} 
              {% if choice.id == request.query_dict.pubtype %}
                &amp;lt;option selected="selected" value="{{ choice.id }}"&amp;gt;{{ choice.name }}&amp;lt;/option&amp;gt;
                {% else %}
                &amp;lt;option value="{{ choice.id }}"&amp;gt;{{ choice.name }}&amp;lt;/option&amp;gt;
                {% endif %} {% endfor %}
            &amp;lt;/select&amp;gt;
        &amp;lt;/div&amp;gt;
&amp;lt;!-- sets the different query parameters using submitted input for hubdb query --&amp;gt;
{% set queryparam = "" %}
{% if request.query_dict.pubtype in ["1","2","3","4","5","6","7","8","9","10","11","12","13"] %}
{% set queryparam = queryparam ~ "&amp;amp;pubtype="~request.query_dict.pubtype|urlencode %}
{% endif %}
{% if request.query_dict.pubtype == "show-all" %}
{% set queryparam = queryparam %}
{% endif %}

{% set table_id = 5344131 %}
  
    &amp;lt;h3&amp;gt;
      Publications:
      &amp;lt;/h3&amp;gt;
        {% for row in hubdb_table_rows(5344131) %}
               &amp;lt;p&amp;gt;
                 {{ row.publication }}
      &amp;lt;/p&amp;gt;  
             
        {% endfor %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 17:07:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592209#M27766</guid>
      <dc:creator>AAM</dc:creator>
      <dc:date>2022-03-10T17:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: HubDB Filter and Results</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592685#M27771</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/71531"&gt;@AAM&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How are you testing your page? To test a HubDB filter you need to publish the module onto a published page.&lt;/P&gt;
&lt;P&gt;Do you have a sample link for your module/page that you can share?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One tip:&lt;BR /&gt;You can replace &lt;CODE&gt;["1","2","3","4","5","6","7","8","9","10","11","12","13"]&lt;/CODE&gt; for &lt;CODE&gt;types|map('id')&lt;/CODE&gt;&amp;nbsp;to make it dynamic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HubSpot has a great tutorial about setting up filter for HubDB.&lt;/P&gt;
&lt;P&gt;I would recommend checking out this tutorial: &lt;A href="https://designers.hubspot.com/docs/tutorials/how-to-build-a-real-estate-listing-with-hubdb" target="_blank" rel="noopener"&gt;Let's Build A Real Estate Listing, using HubDB&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 08:45:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592685#M27771</guid>
      <dc:creator>Indra</dc:creator>
      <dc:date>2022-03-11T08:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: HubDB Filter and Results</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592924#M27782</link>
      <description>&lt;P&gt;Hi Indra. Thank you for your reply. I have the test module embeded in a template on this page:&amp;nbsp;&lt;A href="http://hubspot-developers-v49uvr-21451423.hs-sites.com/hubdb-test" target="_blank"&gt;http://hubspot-developers-v49uvr-21451423.hs-sites.com/hubdb-test&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried following the real estate tutorial and was able to add a search bar, but the page is still not returning results on the filter or search.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Elise&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 15:05:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592924#M27782</guid>
      <dc:creator>AAM</dc:creator>
      <dc:date>2022-03-11T15:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: HubDB Filter and Results</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592960#M27784</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/71531"&gt;@AAM&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see you use the field 'publication' for the search. Is this also your field for your title? Otherwise if won't search correctly. It also looks like the queryparam didn't trigger. So perhaps you haven't added this correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you send your Hubl code?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 15:35:41 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592960#M27784</guid>
      <dc:creator>Indra</dc:creator>
      <dc:date>2022-03-11T15:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: HubDB Filter and Results</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592967#M27785</link>
      <description>&lt;P&gt;Hi Indra,&lt;/P&gt;&lt;P&gt;Here is a snippet from the HubDB table:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AAM_0-1647013334420.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/61489iDB1B63F7682EE21D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AAM_0-1647013334420.png" alt="AAM_0-1647013334420.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And my hubl code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;div&amp;gt;
    &amp;lt;form id="form_id" method="get"&amp;gt;
        &amp;lt;div&amp;gt;
            &amp;lt;h4&amp;gt;Publication Type: &amp;lt;/h4&amp;gt;
            &amp;lt;select name="pubtype" form="form_id" onChange="this.form.submit()"&amp;gt;
                &amp;lt;option value="show-all"&amp;gt;Show All&amp;lt;/option&amp;gt;
                {% set types = hubdb_table_column(5344131, "pubtype").options %} 
              {% for choice in types %} 
              {% set type_list = type_list~choice.id|list%} 
              {% if choice.id == request.query_dict.pubtype %}
                &amp;lt;option selected="selected" value="{{ choice.id }}"&amp;gt;{{ choice.name }}&amp;lt;/option&amp;gt;
                {% else %}
                &amp;lt;option value="{{ choice.id }}"&amp;gt;{{ choice.name }}&amp;lt;/option&amp;gt;
                {% endif %} {% endfor %}
            &amp;lt;/select&amp;gt;
        &amp;lt;/div&amp;gt;
      
    &amp;lt;div&amp;gt;
        &amp;lt;input name="publication" type="text" id="search-by" class="autocomplete" placeholder="Search by Title"&amp;gt;
    &amp;lt;/div&amp;gt;
        &amp;lt;input id="submit-button" type="submit" value="search"&amp;gt;
  &amp;lt;/form&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;!-- sets the different query parameters using submitted input for hubdb query --&amp;gt;
{% set queryparam = "" %}
{% if request.query_dict.pubtype in types|map('5344131') and request.query_dict.publication == "" %}
{% set queryparam = queryparam ~ "&amp;amp;pubtype="~request.query_dict.pubtype|urlencode %}
{% endif %}
{% if request.query_dict.pubtype in types|map('5344131') and request.query_dict.publication != "" %}
    {% set queryparam = queryparam~"&amp;amp;type="~request.query_dict.pubtype|urlencode~"&amp;amp;publication__icontains="~request.query_dict.publication|urlencode %}
{% endif %}
{% if request.query_dict.pubtype == "show-all" and request.query_dict.publication != ""%}
{% set queryparam = queryparam~"publication__icontains="~request.query_dict.publication|urlencode %}
{% endif %}

{% set table_id = 5344131 %}
  
    &amp;lt;h3&amp;gt;
      Publications:
      &amp;lt;/h3&amp;gt;
        {% for row in hubdb_table_rows(5344131) %}
               &amp;lt;p&amp;gt;
                 {{ row.publication }}
      &amp;lt;/p&amp;gt;  
             
        {% endfor %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 15:43:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592967#M27785</guid>
      <dc:creator>AAM</dc:creator>
      <dc:date>2022-03-11T15:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: HubDB Filter and Results</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592978#M27786</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/71531"&gt;@AAM&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try replace &lt;CODE&gt;|map('5344131')&lt;/CODE&gt; for &lt;CODE&gt;|map('id')&lt;/CODE&gt;&amp;nbsp;in your hubl code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;types|maps('id')&lt;/CODE&gt; stands for &lt;CODE&gt;hubdb_table_column(5344131, "pubtype").options|map('id')&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;The map function will only get the ID of your options. So it will give someting back similar as&amp;nbsp;["1","2","3","4","5","6","7","8","9","10","11","12","13"] Only, when editing the 'option', some values will get removed. So this is a more safe way to check on.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 15:54:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592978#M27786</guid>
      <dc:creator>Indra</dc:creator>
      <dc:date>2022-03-11T15:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: HubDB Filter and Results</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592985#M27787</link>
      <description>&lt;P&gt;Thank you for the clarification. Here is what I have now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% set queryparam = "" %}
{% if request.query_dict.pubtype in types|map('id') and request.query_dict.publication == "" %}
{% set queryparam = queryparam ~ "&amp;amp;pubtype="~request.query_dict.pubtype|urlencode %}
{% endif %}
{% if request.query_dict.pubtype in types|map('id') and request.query_dict.publication != "" %}
    {% set queryparam = queryparam~"&amp;amp;type="~request.query_dict.pubtype|urlencode~"&amp;amp;publication__icontains="~request.query_dict.publication|urlencode %}
{% endif %}
{% if request.query_dict.pubtype == "show-all" and request.query_dict.publication != ""%}
{% set queryparam = queryparam~"publication__icontains="~request.query_dict.publication|urlencode %}
{% endif %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still doesn't seem to be working out for me, though.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Mar 2022 16:05:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/592985#M27787</guid>
      <dc:creator>AAM</dc:creator>
      <dc:date>2022-03-11T16:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: HubDB Filter and Results</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/593733#M27798</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/71531"&gt;@AAM&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see there is still a lot of code that is missing. So to really understand the way a &lt;CODE&gt;queryparam&lt;/CODE&gt; is added, you need to apply it to your &lt;CODE&gt;hubdb_table_rows()&lt;/CODE&gt;. I recommand checking yout the documentation about HubDB at &lt;A href="https://developers.hubspot.com/docs/cms/data/hubdb#getting-rows" target="_blank" rel="noopener"&gt;Getting rows&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your code, I have copied your code and made some adjustments to it. This is a working demo if you have the following fields inside your HubDB:&lt;/P&gt;
&lt;P&gt;Column type: Text.&lt;/P&gt;
&lt;P&gt;Column name: publication&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Column type: Select&lt;/P&gt;
&lt;P&gt;Column name:&amp;nbsp;pubtype&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{# Set your HubDB ID. There is a field (HubDB table) to make the user choose. If it's empty, it will display the default #}
{% set db = module.db || '5344131' %}

&amp;lt;!-- sets the different query parameters using submitted input for hubdb query --&amp;gt;
{% set queryparam = "" %}

{# Check if the query_dict of pubtype contains the existing pubtypes of the HubDB column options and append it to the queryparam #}
{% if request.query_dict.pubtype in types|map('id') %}
  {# Set new queryparam by adding the pubtype #}
  {% set queryparam = queryparam ~ "&amp;amp;pubtype="~request.query_dict.pubtype|urlencode %}
{% endif %}

{# Check if the query_dict of publication is not empty and append it to the queryparam #}
{% if request.query_dict.publication != "" %}
  {# Set new queryparam by adding the publication #}
  {% set queryparam = queryparam~"&amp;amp;publication__icontains="~request.query_dict.publication|urlencode %}
{% endif %}

{# Get all rows of your HubDB and apply your queryparam (filter) if it's set #}
{% set rows = hubdb_table_rows(db, queryparam) %}

&amp;lt;div&amp;gt;
  &amp;lt;form id="form_id" method="get"&amp;gt;
    {# Choice filter #}
    &amp;lt;div&amp;gt;
      &amp;lt;h4&amp;gt;Publication Type:&amp;lt;/h4&amp;gt;
      &amp;lt;select name="pubtype" form="form_id" onChange="this.form.submit()"&amp;gt;
        &amp;lt;option value="show-all"&amp;gt;Show All&amp;lt;/option&amp;gt;
        {% set types = hubdb_table_column(db, "pubtype").options %} 
        {% for choice in types %} 
          {% set type_list = type_list~choice.id|list%} 
          &amp;lt;option {% if choice.id == request.query_dict.pubtype %}selected="selected"{% endif %} value="{{ choice.id }}"&amp;gt;{{ choice.name }}&amp;lt;/option&amp;gt;
        {% endfor %}
      &amp;lt;/select&amp;gt;
    &amp;lt;/div&amp;gt;
    {# Search filter #}
    &amp;lt;div&amp;gt;
      &amp;lt;input name="publication" type="text" id="search-by" class="autocomplete" value="{{ request.query_dict.publication }}" placeholder="Search by Title"&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;input id="submit-button" type="submit" value="search"&amp;gt;
  &amp;lt;/form&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;h3&amp;gt;
  Publications:
&amp;lt;/h3&amp;gt;
{# Loop through the rows that has the queryparam #}
{% for row in rows %}
&amp;lt;p&amp;gt;
  {{ row.publication }}
&amp;lt;/p&amp;gt;
{% endfor %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2022 09:57:03 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/593733#M27798</guid>
      <dc:creator>Indra</dc:creator>
      <dc:date>2022-03-13T09:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: HubDB Filter and Results</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/594594#M27818</link>
      <description>&lt;P&gt;Thank you, Indra. That helps!&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 20:12:08 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubDB-Filter-and-Results/m-p/594594#M27818</guid>
      <dc:creator>AAM</dc:creator>
      <dc:date>2022-03-14T20:12:08Z</dc:date>
    </item>
  </channel>
</rss>

