CMS Development

ben-duchy
Top Contributor

Show multiple HubDB field options on webpage

SOLVE

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 %}


Any guidence is appreciated.

0 Upvotes
3 Accepted solutions
shamaleyte
Solution
Participant | Diamond Partner
Participant | Diamond Partner

Show multiple HubDB field options on webpage

SOLVE

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.

 

Hope that helps, 

 

Cheers.

 

 

 

 

 

 

View solution in original post

0 Upvotes
shamaleyte
Solution
Participant | Diamond Partner
Participant | Diamond Partner

Show multiple HubDB field options on webpage

SOLVE

Hello @ben-duchy , 

Calls via HubL methods do not affect the page load performance as they are managed by the server before the page loads 🙂 

So you are good to make multiple calls as long as you do not hit the limitation of max. number of calls. 

Otherwise, there is no way to make a single call to fetch multiple HubDB table content.

Hope that helps!

View solution in original post

0 Upvotes
kosalaindrasiri
Solution
Top Contributor | Partner
Top Contributor | Partner

Show multiple HubDB field options on webpage

SOLVE

Hey @ben-duchy,

 

Unfortunately, hubdb_table_column() doesn’t support fetching multiple columns in a single call like this:

{% set item_list = hubdb_table_column(module.test_hubdb, "bedrooms", "floors").options %}

 

That syntax won't work, HubL requires separate calls per column when accessing .options.

 

But as @shamaleyte explained, you can totally combine those option arrays after fetching them individually.

 

You can also refer: https://developers.hubspot.com/docs/reference/cms/hubl/functions#hubdb_table_column

 

Regards,

Kosala Indrasiri

CEO

Sanmark Solutions
Linkedin
Kosala Indrasiri
emailAddress
kosala@thesanmark.com
website
www.sanmarksolutions.com
linkedinwhatsapp
Book a Consultation

Did my post help answer your question? Mark this as a solution.

View solution in original post

0 Upvotes
6 Replies 6
ben-duchy
Top Contributor

Show multiple HubDB field options on webpage

SOLVE

Thanks @kosalaindrasiri / @shamaleyte, that makes sense.

 

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 %}

 

Jaycee_Lewis
Community Manager
Community Manager

Show multiple HubDB field options on webpage

SOLVE

Hey @ben-duchy 👋 Great instinct.

 

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.


Learn More.





Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
kosalaindrasiri
Solution
Top Contributor | Partner
Top Contributor | Partner

Show multiple HubDB field options on webpage

SOLVE

Hey @ben-duchy,

 

Unfortunately, hubdb_table_column() doesn’t support fetching multiple columns in a single call like this:

{% set item_list = hubdb_table_column(module.test_hubdb, "bedrooms", "floors").options %}

 

That syntax won't work, HubL requires separate calls per column when accessing .options.

 

But as @shamaleyte explained, you can totally combine those option arrays after fetching them individually.

 

You can also refer: https://developers.hubspot.com/docs/reference/cms/hubl/functions#hubdb_table_column

 

Regards,

Kosala Indrasiri

CEO

Sanmark Solutions
Linkedin
Kosala Indrasiri
emailAddress
kosala@thesanmark.com
website
www.sanmarksolutions.com
linkedinwhatsapp
Book a Consultation

Did my post help answer your question? Mark this as a solution.

0 Upvotes
shamaleyte
Solution
Participant | Diamond Partner
Participant | Diamond Partner

Show multiple HubDB field options on webpage

SOLVE

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.

 

Hope that helps, 

 

Cheers.

 

 

 

 

 

 

0 Upvotes
ben-duchy
Top Contributor

Show multiple HubDB field options on webpage

SOLVE

@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.

0 Upvotes
shamaleyte
Solution
Participant | Diamond Partner
Participant | Diamond Partner

Show multiple HubDB field options on webpage

SOLVE

Hello @ben-duchy , 

Calls via HubL methods do not affect the page load performance as they are managed by the server before the page loads 🙂 

So you are good to make multiple calls as long as you do not hit the limitation of max. number of calls. 

Otherwise, there is no way to make a single call to fetch multiple HubDB table content.

Hope that helps!

0 Upvotes