Aug 21, 20183:01 AM - edited Aug 21, 20183:02 AM
Thought Leader | Partner
HubDB filtering by custom module
SOLVE
Hi,
I'm currently building a custom module for a customer and got stuck on the "filter-feature".
The customer wants to have the functionality that he inserts one module an then selects an option for "filter the rows by column option".
I've got a HubDB Column with "industry" which is an option col. In the custom module I've insert an "selection" function and wanted to do something like
{% if widget.branche =='1'%}
{% set table = hubdb_table_rows(XXXXXX, ‘industry=Option1’) %}
{% elif widget.branche =='2'%}
{% set table = hubdb_table_rows(XXXXXX, ‘industry=Option2’) %}
{% endif %}
Option1 and Option2 are some placeholders for the options in the industry column.
What am I doing wrong and could someone provide me help, please?
@Anton - if this is a custom module in the design manager that you're editing. I think you're looking for "module.branche" not "widget.branche". Test your output with
{{module.branche|pprint}}
this will help you debug in the future
If this answer helped, please, mark as solved 😄
tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.
{% if widget.branche =='1'%}
{% set table = hubdb_table_rows(XXXXXX, ‘industry=Anlagenbau’) %}
{% elif widget.branche =='2'%}
{% set table = hubdb_table_rows(XXXXXX, ‘industry=Automotive’) %}
{% endif %}
part is, like the "widget.job_anzahl", an option(or widget) which is build into the module. Where the user/customer can customize the result that is shown by the module.
@Anton - Let's just make sure the "if" statements are the one's causing you problems. Can you drop this code in your module and toggle between your choices to at least make sure the if statements aren't evaluating properly?
when I'm dropping your "code" into the module and toggle between the the choises I can see "branch = 1 " or "branch = 2 ". So the if-statement is correct
edit:
Does it make any difference between a "select" and "multiselect"-column type for the "industry=XY"-part?
{% set table = hubdb_table_rows(XXXXXX, ‘industry=Anlagenbau’) %}
Just asking because the "industry" column is a multiselect-column
@Anton - Make sure you aren't querying the Hubdb by the label name, instead you should query it by the key value. Each dropdown option will have a value => label pair.
So, if your select looks like this for the industry in hubdb
<option value="1">Anlagenbau</option>
Your query should look like this:
{% set table = hubdb_table_rows(XXXXXX, ‘industry=1’) %}
{% set table = hubdb_table_rows(XXXXXX, ‘industry=Anlagenbau’) %}