CMS Development

krissyhack
Member

Creating a dropdown to filter data from HubDB table

Hi! Working on creating a drop down to sort hub db values based on price. Can't seem to find a solution to sort based on value ($100,000 increments). We created a similar dropdown to filter by neighborhoods, but when it comes to numerical values, we are having some issues. See page for referencing: https://www.creativehci.com/properties.

 

Dropdown for sorting by neighborhood has following code. hoping to tweak this for numerical values by price

 

 <div class="properties-container">
<div class="select-container">
<select class="resources-select">
<option>Select Neighborhood</option>
<option value="all">All Neighborhoods</option>
{% set types = hubdb_table_column(966992, "neighborhood_type").options %}
{% for choice in types %}
{% set type_list = type_list~choice.id|list%}
<option value="{{ choice.name|lower|replace(' ', '-') }}">{{ choice.name }}</option>
{% endfor %}

0 Upvotes
1 Reply 1
MitchL
Participant

Creating a dropdown to filter data from HubDB table

Hey @krissyhack,

 

I'm not 100% certain this would work as I have used this exact method, but it might. 

 

Add this line above you hubdb table query (substituting 'price' for the name of the column you're sorting by):

{% set queryparam = “&orderBy=price” %}

 

And then change your hubdb table query to this:

{% set types = hubdb_table_column(966992, queryparam).options %}

 

Hope this works,

Mitch

0 Upvotes