CMS Development

ashleyidesign
Top Contributor | Partner
Top Contributor | Partner

HubDB Multiple Filtering

I'm working on a portfolio for a client, but running into an issue trying to create two dropdowns for filtering. The first one is working fine (Room) but the second is not (Style).

 

I have a feeling it's related to the if statements but my brain is fried from learning all this today.

 

<div>
<form id="form_id" method="get">
    <div>
        <h4>FILTER BY ROOM TYPE: </h4>
        <select name="room" form="form_id" onChange="this.form.submit()">
            <option value="show-all">Show All</option>
            {% set rooms = hubdb_table_column(602647, "Room").options %}
            {% for choice in rooms %}
                {% set room_list = room_list~choice.id|list%}
                {% if choice.id == request.query_dict.room%}
                    <option selected="selected" value="{{ choice.id }}">{{ choice.name }}</option>
                {% else %}
                    <option value="{{ choice.id }}">{{ choice.name }}</option>
                {% endif %}
            {% endfor %}
        </select>
        <h4>FILTER BY STYLE TYPE: </h4>
        <select name="style" form="form_id" onChange="this.form.submit()">
            <option value="show-all">Show All</option>
            {% set styles = hubdb_table_column(602647, "Style").options %}
            {% for choice in styles %}
                {% set style_list = style_list~choice.id|list%}
                {% if choice.id == request.query_dict.style%}
                    <option selected="selected" value="{{ choice.id }}">{{ choice.name }}</option>
                {% else %}
                    <option value="{{ choice.id }}">{{ choice.name }}</option>
                {% endif %}
            {% endfor %}
        </select>
    </div>
    
</form>
</div>
{% set roomquery = "&orderBy=-name" %}
{% if request.query_dict.room in ["1", "2", "3", "4", "5"] %}
    {% set roomquery = roomquery ~ "&room="~request.query_dict.room|urlencode %}
{% endif %}
{% if request.query_dict.room == "show-all" %}
    {% set roomquery = roomquery %}
{% endif %}
{% set stylequery = "" %}
{% if request.query_dict.style in ["1", "2", "3", "4", "5"] %}
    {% set stylequery = stylequery ~ "&style="~request.query_dict.style|urlencode %}
{% endif %}
{% if request.query_dict.style == "show-all" %}
    {% set stylequery = stylequery %}
{% endif %}
<div class="row-fluid">
{% set table = hubdb_table_rows(602647, roomquery, stylequery) %}
    {% for row in table %}
        <div class="portfolio-item span3">
           <a href="{{ row.slider_url }}">
               <div class="portfolio-image">
                   {% if row.featured_image.url %}
            <img src="{{ row.featured_image.url }}" width="{{ row.featured_image.width }}" height="{{ row.featured_image.height }}" alt="{{ row.name }}">
        {% endif %}
                   <div class="portfolio-overlay">
                       <h6 class="portfolio-title">
                           {{ row.hover_text }}
                       </h6>
                   </div>
               </div>
           </a>
        </div>
    {% endfor %}
</div>
0 Upvotes
4 Replies 4
Myriad
Member

HubDB Multiple Filtering

New to hubspot but my guess is your problem is 

<div class="row-fluid">
{% set table = hubdb_table_rows(602647, roomquery, stylequery) %}
    {% for row in table %}

If that doesn't work trying combining the query parameter into one statement  

<div class="row-fluid">
{% set table = hubdb_table_rows(602647, roomquery + stylequery) %}
    {% for row in table %}

 

TRooInbound
Key Advisor

HubDB Multiple Filtering

Hi @Myriad,

 

Yes, this solution is working for me!

Thanks For advice

0 Upvotes
ashleyidesign
Top Contributor | Partner
Top Contributor | Partner

HubDB Multiple Filtering

Anyone have some insight?

0 Upvotes
jmarshall
Participant

HubDB Multiple Filtering

Did you ever figure this out? I'm having the same issue.

0 Upvotes