I'm creating a new module that displays the options from a specific HubDB field and I would like to know whether it's possible to combine multiple calls or if they have to remain seperate?
Current HubDB call examples:
{% set bedrooms_list = hubdb_table_column(module.test_hubdb, "bedrooms").options %}
{% set floors_list = hubdb_table_column(module.test_hubdb, "floors").options %}
Result:
{% for choice in bedroom_list %}
<li>{{ choice.name }}</li>
{% endfor %}
{% for choice in floors_list %}
<li>{{ choice.name }}</li>
{% endfor %}
You can definitely combine multiple HubDB field option calls into a single list, especially if you’re just trying to render them all in one output block.
If the goal is to merge the two lists into one loop, you can use the + operator in HubL, like this:
{% set bedrooms_list = hubdb_table_column(module.test_hubdb, "bedrooms").options %} {% set floors_list = hubdb_table_column(module.test_hubdb, "floors").options %} {% set combined_list = bedrooms_list + floors_list %}
<ul> {% for choice in combined_list %} <li>{{ choice.name }}</li> {% endfor %} </ul>
This will output all the options from both bedrooms and floors in one unified list.
Just one final question, with there being a limit on how many times the database can be called on one page, is it possible to use an initial call to the database for these option type calls thus reducing it to just 1 call?
For example:
{% set test_database = hubdb_table_rows(1234567, "&limit=10000") %}
{% set bedrooms_list = hubdb_table_column(test_database, "bedrooms").options %}
{% set floors_list = hubdb_table_column(test_database, "floors").options %}
The root problem is that the hubdb_table_column function requires the table's unique ID as its input, not the array of row data that the hubdb_table_rows function provides.
The HubL functions require separate calls for each set of column options. So the options offered by @shamaleyte and @kosalaindrasiri are spot on 🙌
Best,
Jaycee
HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
You can definitely combine multiple HubDB field option calls into a single list, especially if you’re just trying to render them all in one output block.
If the goal is to merge the two lists into one loop, you can use the + operator in HubL, like this:
{% set bedrooms_list = hubdb_table_column(module.test_hubdb, "bedrooms").options %} {% set floors_list = hubdb_table_column(module.test_hubdb, "floors").options %} {% set combined_list = bedrooms_list + floors_list %}
<ul> {% for choice in combined_list %} <li>{{ choice.name }}</li> {% endfor %} </ul>
This will output all the options from both bedrooms and floors in one unified list.
@shamaleyte, good idea, but is there a way to combine them on the same call for example:
{% set item_list = hubdb_table_column(module.test_hubdb, "bedrooms", "floors").options %}
The reason for this is because I have around 8 'list' field types in the database that I want to display on my webpage and I understand that too many calls may affect page speed.