<?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: How to render filters used on page ex. &amp;quot;Showing results for [filter 1], [filter 2], [filter in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418786#M21732</link>
    <description>&lt;P&gt;Lot of text I only skimmed it, but high level you seem to have the query params and a lot of code surrounding it.... Why not just use that to build a string dynamically with the search description and display it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although.... I think this is an anti-pattern. When a users selects search criteria and new results are displayed they know what they've filtered..... and with a multi-select that description can become overly verbose unless truncated to some high level description which is the antithesis of verbosity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want it for ARIA announcements then sure.... That's useful for people with visual impairments and disabilities.&lt;/P&gt;&lt;P&gt;There are patterns to achieve this, but I don't think that's what you're getting at here.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Mar 2021 18:51:46 GMT</pubDate>
    <dc:creator>Ntbrown</dc:creator>
    <dc:date>2021-03-15T18:51:46Z</dc:date>
    <item>
      <title>How to render filters used on page ex. "Showing results for [filter 1], [filter 2], [filter 3]"</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418748#M21728</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to figure out how to render onto the page the values that were used to filter my database. Currently I'm using a select filter, a multi-select/checkbox filter and a search filter.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I would like to render something like "Showing results for &lt;STRONG&gt;Resellers&lt;/STRONG&gt; in the &lt;STRONG&gt;United States&lt;/STRONG&gt; associted with&lt;STRONG&gt; AirParrot&lt;/STRONG&gt;" when the results are shown.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Would appreciated any help!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is my code:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;!-- set the filter by drop down, search bar, and submit button --&amp;gt;

&amp;lt;div&amp;gt;
&amp;lt;form id="form_id" method="GET" style="text-align: center"&amp;gt;
&amp;lt;!--Dropdown --&amp;gt;
{% if module.show_hide_partner_type %}

    &amp;lt;div&amp;gt;
        &amp;lt;h4&amp;gt;Filter by partner type: &amp;lt;/h4&amp;gt;
        &amp;lt;select name="partner_type" form="form_id"&amp;gt;
            &amp;lt;option value="show-all"&amp;gt;Show All&amp;lt;/option&amp;gt;
            {% set partner_type = hubdb_table_column((3420769), "partner_type").options %}
            {% for partner in partner_type %}
                {% set partner_list = partner_list~partner.id|list %}
                {% if partner.id == request.query_dict.partner_type %}
                    &amp;lt;option selected="selected" value="{{ partner.id }}"&amp;gt;{{ partner.name }}&amp;lt;/option&amp;gt;
                {% else %}
                    &amp;lt;option value="{{ partner.id }}"&amp;gt;{{ partner.name }}&amp;lt;/option&amp;gt;
                {% endif %}
            {% endfor %}
        &amp;lt;/select&amp;gt;
    &amp;lt;/div&amp;gt;

{% endif %}
  
  
&amp;lt;!-- Multi-select --&amp;gt;
  {% if module.show_hide_partner_product %}

      &amp;lt;div&amp;gt;
        &amp;lt;h4&amp;gt;Filter by partner product: &amp;lt;/h4&amp;gt;
          {% set partner_products = hubdb_table_column((3420769), "partner_products").options %}
          {% for product in partner_products %}
            {% set product_list = product_list~product.id|list%}
            {% if product.id == request.query_dict.partner_products%}
              &amp;lt;input type="checkbox" id="{{product.id}}" name="partner_products" value="{{product.id}}"&amp;gt;
              &amp;lt;label for="{{product.name}}"&amp;gt;  {{product.name}}&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
            {% else %}
              &amp;lt;input type="checkbox" id="{{product.id}}" name="partner_products" value="{{product.id}}"&amp;gt;
              &amp;lt;label for="{{product.name}}"&amp;gt;  {{product.name}}&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
            {% endif %}
          {% endfor %}
      &amp;lt;/div&amp;gt;
  
{% endif %}
  
&amp;lt;!-- Search --&amp;gt;
{% if module.show_hide_search %}

 &amp;lt;div&amp;gt;
   &amp;lt;h4&amp;gt;Filter by partner country: &amp;lt;/h4&amp;gt;
   &amp;lt;input name="partner_country" type="text" id="search-by" class="autocomplete" placeholder="Search by Country"&amp;gt;
 &amp;lt;/div&amp;gt;
{% endif %}
  &amp;lt;div style="margin-top: 20px"&amp;gt;
    &amp;lt;input id="submit-button" type="submit" value="Enter"&amp;gt;
    &amp;lt;div style="margin-top: 20px"&amp;gt;
       &amp;lt;a href="/test-partner-locator-page"&amp;gt;Reset Filters&amp;lt;/a&amp;gt;
    &amp;lt;/div&amp;gt;
   
  &amp;lt;/div&amp;gt;

&amp;lt;/form&amp;gt;
&amp;lt;/div&amp;gt;



{% set queryparam = "" %}
&amp;lt;!-- Dropdown Selection + No Country Entry --&amp;gt;
{% if request.query_dict.partner_type in ["1", "2"] and request.query_dict.partner_country == "" %}
    {% set queryparam = queryparam ~ "&amp;amp;partner_type="~request.query_dict.partner_type|urlencode %}
{% endif %}
&amp;lt;!-- Dropdown Selection + Country Entry --&amp;gt;
{% if request.query_dict.partner_type in ["1", "2"] and request.query_dict.partner_country != "" %}
    {% set queryparam = queryparam ~ "&amp;amp;partner_type="~request.query_dict.partner_type|urlencode~"&amp;amp;partner_country__contains="~request.query_dict.partner_country|urlencode %}
{% endif %}
&amp;lt;!-- Multi-Select Selection + No Country Entry --&amp;gt;
{% if request.query_dict.partner_products in ["1", "2", "3"] and request.query_dict.partner_country == "" %}
    {% set queryparam = queryparam ~ "&amp;amp;partner_products__in="~request.query_dict.partner_products|urlencode %}
{% endif %}
&amp;lt;!-- Multi-Select Selection + Country Entry --&amp;gt;
{% if request.query_dict.partner_products in ["1", "2", "3"] and request.query_dict.partner_country != "" %}
  {% set queryparam = queryparam ~ "&amp;amp;partner_products__in="~request.query_dict.partner_products|urlencode~"&amp;amp;partner_country__contains="~request.query_dict.partner_country|urlencode %}
{% endif %}
&amp;lt;!-- No Dropdown or Multi-Select + Country Search --&amp;gt;
{% if request.query_dict.partner_type == "show-all" and request.query_dict.partner_products == "show-all" and request.query_dict.partner_country != "" %}
    {% set queryparam = queryparam~"&amp;amp;partner_country__contains="~request.query_dict.partner_country|urlencode %}
{% endif %}
&amp;lt;!-- If Dropdown or Multi-Select is hidden, still allow search to function --&amp;gt;
{% if request.query_dict.partner_type == "show-all" or request.query_dict.partner_products == "" and request.query_dict.partner_country != "" %}
    {% set queryparam = queryparam~"&amp;amp;partner_country__contains="~request.query_dict.partner_country|urlencode %}
{% endif %}
{% if request.query_dict.partner_type == "" or request.query_dict.partner_products == "show-all" and request.query_dict.partner_country != "" %}
    {% set queryparam = queryparam~"&amp;amp;partner_country__contains="~request.query_dict.partner_country|urlencode %}
{% endif %}
&amp;lt;!-- Show All + No Country Entry --&amp;gt;
{% if request.query_dict.partner_type == "show-all" and request.query_dict.partner_products == "show-all" %}
    {% set queryparam = queryparam %}
{% endif %}

&amp;lt;!-- end --&amp;gt;

{% set table = hubdb_table_rows((3420769), queryparam) %}


{% if table == [] %}
    &amp;lt;p class='align-center'&amp;gt;Sorry, no listings found for that Search. Try changing your filter and search again.&amp;lt;/p&amp;gt;
{% else %}
  {% for row in table %}
&amp;lt;div&amp;gt;
    &amp;lt;div class="{{ row["partner_type"].name }}"&amp;gt;
            &amp;lt;div&amp;gt;
              &amp;lt;div class="item"&amp;gt;
                &amp;lt;h4&amp;gt;Partner:&amp;lt;/h4&amp;gt;
                 &amp;lt;p&amp;gt;{{ row.partner_name }}&amp;lt;/p&amp;gt;
               &amp;lt;/div&amp;gt;
              
              &amp;lt;div class="item"&amp;gt;
                &amp;lt;h4&amp;gt;Partner Type:&amp;lt;/h4&amp;gt;
                &amp;lt;p&amp;gt;{{ row.partner_type.name }}&amp;lt;/p&amp;gt;
              &amp;lt;/div&amp;gt;
              
              &amp;lt;div class="item"&amp;gt;
                &amp;lt;h4&amp;gt;Partner Country:&amp;lt;/h4&amp;gt;
                &amp;lt;p&amp;gt;{{ row.partner_country}}&amp;lt;/p&amp;gt;
              &amp;lt;/div&amp;gt;
             
              &amp;lt;div class="item"&amp;gt;
                 &amp;lt;h4&amp;gt;Partner Products:&amp;lt;/h4&amp;gt;
                  {% for product in row.partner_products %}
                    {{ product.name }}{% if !loop.last %}, {% endif %}
                  {% endfor %}
              &amp;lt;/div&amp;gt;
             
              &amp;lt;hr&amp;gt;
            &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;            
&amp;lt;/div&amp;gt;
  {% endfor %}
{% endif %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 17:29:02 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418748#M21728</guid>
      <dc:creator>ckingg</dc:creator>
      <dc:date>2021-03-15T17:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to render filters used on page ex. "Showing results for [filter 1], [filter 2], [filter</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418786#M21732</link>
      <description>&lt;P&gt;Lot of text I only skimmed it, but high level you seem to have the query params and a lot of code surrounding it.... Why not just use that to build a string dynamically with the search description and display it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although.... I think this is an anti-pattern. When a users selects search criteria and new results are displayed they know what they've filtered..... and with a multi-select that description can become overly verbose unless truncated to some high level description which is the antithesis of verbosity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want it for ARIA announcements then sure.... That's useful for people with visual impairments and disabilities.&lt;/P&gt;&lt;P&gt;There are patterns to achieve this, but I don't think that's what you're getting at here.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 18:51:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418786#M21732</guid>
      <dc:creator>Ntbrown</dc:creator>
      <dc:date>2021-03-15T18:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to render filters used on page ex. "Showing results for [filter 1], [filter 2], [filter</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418791#M21733</link>
      <description>&lt;P&gt;Thanks for the reply&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/118753"&gt;@Ntbrown&lt;/a&gt;. I could probably pass on displaying the filters in the search results. However, when I hit enter to begin filtering, the checkboxes and search box are cleared and don't show what the user searched for after the results are displayed.&amp;nbsp; Any idea how I can prevent those from clearing upon submit?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Also, for what it's worth, I've tried working through my initial questions and I can get the table item ID to display (this is the only one I've tried so far) after hitting submit with&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; {% set display = request.query_dict.partner_type %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;And using&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{{ display }}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To render the table item ID associated with the filter when the filter is applied, but I can't get it to render the name of the table item.&lt;BR /&gt;Does that make sense?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 18:59:02 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418791#M21733</guid>
      <dc:creator>ckingg</dc:creator>
      <dc:date>2021-03-15T18:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to render filters used on page ex. "Showing results for [filter 1], [filter 2], [filter</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418889#M21736</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/170856"&gt;@ckingg&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what does&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{{ display }}&lt;/LI-CODE&gt;
&lt;P&gt;show you, when you &lt;A href="https://developers.hubspot.com/docs/cms/hubl/filters#pprint" target="_blank" rel="noopener"&gt;pprint&lt;/A&gt; it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anton&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 22:09:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418889#M21736</guid>
      <dc:creator>Anton</dc:creator>
      <dc:date>2021-03-15T22:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to render filters used on page ex. "Showing results for [filter 1], [filter 2], [filter</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418910#M21737</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/17186"&gt;@Anton&lt;/a&gt;&amp;nbsp;it shows:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;SPAN&gt;(String: 1)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 23:35:13 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418910#M21737</guid>
      <dc:creator>ckingg</dc:creator>
      <dc:date>2021-03-15T23:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to render filters used on page ex. "Showing results for [filter 1], [filter 2], [filter</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418977#M21740</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/170856"&gt;@ckingg&lt;/a&gt;&amp;nbsp;- Here's how I would do it...&lt;/P&gt;
&lt;P&gt;I would start pushing javascript variables to your window object... for example, in your "partners" select field logic you have a for loop... you could use the same for loop to push variables to the window&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;
  window.CHOSEN_QUERY_PARAMS = {
    partner: '',
    country: '',
    association: ''
  };
&amp;lt;/script&amp;gt;
{% set partner_type = hubdb_table_column((3420769), "partner_type").options %}
{% for partner in partner_type %}
   {% set partner_list = partner_list~partner.id|list %}
      {% if partner.id == request.query_dict.partner_type %}
         &amp;lt;script&amp;gt;window.CHOSEN_QUERY_PARAMS.partner = '{{partner.name}}';&amp;lt;/script&amp;gt;
      {% endif %}
   {% endfor %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then your helper text would look like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Showing results for &amp;lt;span class="uni-chosen-partner"&amp;gt;&amp;lt;/span&amp;gt; in the &amp;lt;span class="uni-chosen-country"&amp;gt;&amp;lt;/span&amp;gt; associted with &amp;lt;span class="uni-chosen-association"&amp;gt;&amp;lt;/span&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and finally, your footer script would look like this&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;
  $(function(){
    $('.uni-chosen-partner').text(window.CHOSEN_QUERY_PARAMS.partner);
    $('.uni-chosen-country').text(window.CHOSEN_QUERY_PARAMS.country);
    $('.uni-chosen-association').text(window.CHOSEN_QUERY_PARAMS.association);
  });
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as you're not worried about SEO for this text, this is the easiest way to get around variable and object scoping in HUBL using foreach loops.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, If you do want to stick with HUBL to render this text... take a look at this guide here&amp;nbsp;&lt;A href="https://community.hubspot.com/t5/CMS-Development/How-to-change-a-variable-outside-of-a-for-loop-Scoping-Issues/td-p/211117" target="_blank"&gt;https://community.hubspot.com/t5/CMS-Development/How-to-change-a-variable-outside-of-a-for-loop-Scoping-Issues/td-p/211117&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;JavaScript is just much simpler... hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 09:08:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-render-filters-used-on-page-ex-quot-Showing-results-for/m-p/418977#M21740</guid>
      <dc:creator>tjoyce</dc:creator>
      <dc:date>2021-03-16T09:08:22Z</dc:date>
    </item>
  </channel>
</rss>

