CMS Development

subin
Stratege/Strategin | Gold Partner
Stratege/Strategin | Gold Partner

How to filter a HubDB query with a column value

lösung

Hi developers

 

I am developing a listing page using HubDB, 

1.png

 

Here how i can fetch the rows with popularity "popular" with limit 5.

 I have tried some queries but none of them are working, can anyone help me with some queries 

 

Thanks

1 Akzeptierte Lösung
boulter
Lösung
HubSpot-Produktteam
HubSpot-Produktteam

How to filter a HubDB query with a column value

lösung
{{ hubdb_table_rows(<tableId>, ‘popularity=<optionid>&limit=5’) }}

where <optionid> is the id of the "popular" or "not popular" option.

 

See https://developers.hubspot.com/docs/cms/hubl/functions#hubdb-table-rows for thorough documentation.

Lösung in ursprünglichem Beitrag anzeigen

7 Antworten
boulter
Lösung
HubSpot-Produktteam
HubSpot-Produktteam

How to filter a HubDB query with a column value

lösung
{{ hubdb_table_rows(<tableId>, ‘popularity=<optionid>&limit=5’) }}

where <optionid> is the id of the "popular" or "not popular" option.

 

See https://developers.hubspot.com/docs/cms/hubl/functions#hubdb-table-rows for thorough documentation.

leckerman
Stratege/Strategin

How to filter a HubDB query with a column value

lösung

How do you determine what the <optionid> is for the "popular" or "not popular" dropdown options in the table?

 

I'm trying to create a custom module with “Choice options” that allow you to filter and show options on a page based on what is selected in the HubDB table's column. For example, I want all of our upcoming “Essentials” classes to be listed on a page using a custom module. Not sure I am doing this correctly...

 

I believe the value in the custom module would be something like…

{{ hubdb_table_rows (674971, ‘select_course=<optionid>') }}

 

select_course_dropdown.gif

0 Upvotes
boulter
HubSpot-Produktteam
HubSpot-Produktteam

How to filter a HubDB query with a column value

lösung

Sure, you can use the hubdb_table_column hubl tag to get the list of options and then the getOptionByName method to get the option value. See http://designers.hubspot.com/docs/tools/hubdb

0 Upvotes
leckerman
Stratege/Strategin

How to filter a HubDB query with a column value

lösung

Can you tell me what I am doing wrong with these custom module values? How/where do I add what other columns in the table I want to be shown based on the course selected? Is this close? Not working as is...


Value 1:

{{ hubdb_table_column (674971, select_course=getOptionByName("Essentials") }}<h3>{{ row.course_name }}</h3><p><strong>Location:</strong> {{ row.class_location }}<br><strong>Date:</strong> {{row.date|datetimeformat('%A, %B %e, %Y') }}</p>{% endfor %}

 

 

Value 2:

{{ hubdb_table_column (674971, select_course=getOptionByName("Drawings") }}<h3>{{ row.course_name }}</h3><p><strong>Location:</strong> {{ row.class_location }}<br><strong>Date:</strong> {{row.date|datetimeformat('%A, %B %e, %Y') }}</p>{% endfor %}

 

Value 3:

{{ hubdb_table_column (674971, select_course=getOptionByName("Composer") }}<h3>{{ row.course_name }}</h3><p><strong>Location:</strong> {{ row.class_location }}<br><strong>Date:</strong> {{row.date|datetimeformat('%A, %B %e, %Y') }}</p>{% endfor %}

 

0 Upvotes
boulter
HubSpot-Produktteam
HubSpot-Produktteam

How to filter a HubDB query with a column value

lösung

Try something like this:

{% set col = hubdb_table_column (674971, <columnId>) %} 

{% set selected_course = col.getOptionByName("Essentials") %}

{{ selected_course }}
 
0 Upvotes
leckerman
Stratege/Strategin

How to filter a HubDB query with a column value

lösung

Is the <columnId> just the name of the column select_course? I can't find id numbers for the table columns. Tried inserting the following into the custom module value choices and then then name of the widget {{ widget.select_course }} into the "Edit" field. Nothing shows up in preview. 

 

Value 1:
{% set col = hubdb_table_column (674971, select_course) %} {% set select_course = col.getOptionByName("Essentials") %}{{ select_course }}<h3>{{ row.course_name }}</h3><p><strong>Location:</strong> {{ row.class_location }}<br><strong>Date:</strong> {{row.date|datetimeformat('%A, %B %e, %Y') }}</p>

 

Value 2:
{% set col = hubdb_table_column (674971, select_course) %} {% set select_course = col.getOptionByName("Drawings") %}{{ select_course }}<h3>{{ row.course_name }}</h3><p><strong>Location:</strong> {{ row.class_location }}<br><strong>Date:</strong> {{row.date|datetimeformat('%A, %B %e, %Y') }}</p>


Value 3:
{% set col = hubdb_table_column (674971, select_course) %} {% set select_course = col.getOptionByName("Composer") %}{{ select_course }}<h3>{{ row.course_name }}</h3><p><strong>Location:</strong> {{ row.class_location }}<br><strong>Date:</strong> {{row.date|datetimeformat('%A, %B %e, %Y') }}</p>

 

0 Upvotes
subin
Stratege/Strategin | Gold Partner
Stratege/Strategin | Gold Partner

How to filter a HubDB query with a column value

lösung

Thanks @boulter this solved my problem, i have directly used the dropdown value

 

ThanksSmiley (fröhlich)Herz

0 Upvotes