hubdb filtered results

marvelouspatric
Member

Hello,

 

I want to state to begin with, I am a bad coder, so there's a good chance this is a very simple thing I'm missing.  That said, I'm trying to build a custom module based on the real estate listing example using hubdb http://designers.hubspot.com/docs/tutorials/how-to-build-a-real-estate-listing-with-hubdb .  I couldn't get that example to work either, same problem.  

 

The problem I'm running into is no matter what I select, the displayed entries never filter. Here's my code:

 

<!-- 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>

</form>
</div>


{% 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 class="team-member-card-container {{ widget.cards_in_row }}">
<div class="team-member-card">
<div class="image-container">
<img src="{{ row.image_url.url }}" width="500" {% if row.image.width > row.image.height %}class="landscape"{% endif %} alt="{{ row.name }} Headshot">
</div>
<div class="team-member-info">
<h3>{{ row.property_name }}</h3>
<h4>{{ row.state }}</h4>
<p>{{ row.description }}</p>
<p>${{ row.price }}</p>
<p>Contact {{ row.contact }} if interested.</p>
<p></p>
</div>
</div>
</div>
{% endfor %}
{% endif %}

 

 

thank you in advance!

 

patric

0 Upvotes
2 Replies 2
DaniellePeters
Top Contributor

Have you included the code snippet from the example that sets the "queryparam" variable (Steps 4-6)?

0 Upvotes
marvelouspatric
Member

Yes...  I may not have copied the right code.  I gave a different test I was running than the actual (neither worked).

 

code:

 

<!-- 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>

</form>

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