Fetch HubDb Data into HubSpot Modules

hubdb

First step is to Grab the id from the Hubdb table.

 

Id which we are going to use is 5252243

<!-- variable contains all unfiltered table data -->
{% set data = hubdb_table_rows(5252243) %}


<!-- Loop through each row  -->
{% for row in data %}
  <!--Print your each row -->
  {{row|pprint}}
  
{% endfor %}

Each row returns an object. So you can easily access any field data with dot notation.

<!-- variable contains all unfiltered table data -->
{% set hubdbdata = hubdb_table_rows(5244337) %}


<!-- Loop through each row  -->
{% for row in hubdbdata %}
  <article class="basic-card">
    <img src="{{row.image.url}}" alt"{{row.name}}"/>
    <h3 class="name">{{row.name}}</h3>
    <span class="category">{{row.category}}</span>
  </article>
{% endfor %}

if you want to make your Hubdb  table id option more user-friendly means giving the  ability to use to change your  Hubdb  table from page editor then:

HubDb

 

Select Hubdb Option and replace and copy its value and replace hubdb id with its value eg: 5252243 with module.hubdbtable_field

 

<!-- variable contains all unfiltered table data -->
{% set hubdbdata = hubdb_table_rows(module.hubdbtable_field) %}


<!-- Loop through each row  -->
{% for row in hubdbdata %}
  <article class="basic-card">
    <img src="{{row.image.url}}" alt"{{row.name}}"/>
    <h3 class="name">{{row.name}}</h3>
    <span class="category">{{row.category}}</span>
  </article>
{% endfor %}

Roger now you can select any table from list to fetch

select table


Read More