Search and Filter Not Working on HubDB

marvelouspatric
Member

Hello,

 

I never got an answer to this.  I've tried on my own, but I just can't get this code to work.  The results don't filter by type.  Here's the code.  I am desperate for help.

<!-- set the filter by drop down, search bar, and submit button -->

<div>
<form id="form_id" method="get">

<div>
<h4>FILTER BY LISTING TYPE: </h4>
<select name="type" form="form_id" onChange="this.form.submit()">
<option value="show-all">Show All</option>
{% set types = hubdb_table_column(658781, "type").options %}
{% for choice in types %}
{% set type_list = type_list~choice.id|list%}
{% if choice.id == request.query_dict.type%}
<option selected="selected" value="{{ choice.id }}">{{ choice.name }}</option>
{% else %}
<option value="{{ choice.id }}">{{ choice.name }}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div>
<input name="state" type="text" id="search-by" class="autocomplete" placeholder="Search by State.">
</div>
<input id="submit-button" type="submit" value="search">
</form>

<!-- sets the different query parameters using submitted input for hubdb query -->
{% set queryparam = "" %}
{% if request.query_dict.type in ["1", "2", "3", "4"] and request.query_dict.listing_address == "" %}
{% set queryparam = queryparam ~ "&type="~request.query_dict.type|urlencode %}
{% endif %}
{% if request.query_dict.type in ["1", "2", "3", "4"] and request.query_dict.listing_address != "" %}
{% set queryparam = queryparam~"&type="~request.query_dict.type|urlencode~"&listing_address__icontains="~request.query_dict.listing_address|urlencode %}
{% endif %}
{% if request.query_dict.type == "show-all" and request.query_dict.listing_address != "" %}
{% set queryparam = queryparam~"&listing_address__icontains="~request.query_dict.listing_address|urlencode %}
{% endif %}

</div>
<!-- main table -->

{% set table = hubdb_table_rows(658781, queryparam) %}

{% if table == [] %}
<p class='align-center'>Sorry, no listings found for that Search. Try changing your fiter and search again.</p>
{% else %}
{% for row in table %}
<div>
<div class="{{ row["type"].name }}">
<div><img src="{{ row["image_url"].url}}" height="200"></div>
<div>
<h2>{{ row["property_name"] }}</h2>
<h2>${{ row["price"] }}</h2>
<h3>{{ row["state"] }}</h3>

<div>
<ul>
<li><span>{{ row["description"] }}</span></li>
<li><span>Contact {{ row["contact"] }} if interested.</span></li>

</div>

</div>
</div>
</div>
{% endfor %}
{% endif %}

0 Upvotes
1 Reply 1
roisinkirby
HubSpot Product Team

Hey @marvelouspatric is this still something you are working on or were you able to find a solution? If not I'm happy to connect you with some of our design experts Smiley Happy

0 Upvotes