Jul 24, 202011:32 AM - edited Jul 24, 202011:35 AM
Key Advisor
Possible to loop over multiple HubDBs in a module?
SOLVE
Is it possible to loop over, and access, the data from multiple HubDBs in a custom module?
For example I can do this and it returns the HubDB table id, but only the id
{% for item in module.hubdbtable %}{{item}}{% endfor %}>
However, when you do this, the id is invalid and I get the error "Table `` not found in your account."
{% for item in module.hubdbtable %} {% set id = item %}
{% set table = hubdb_table_rows(id) %}
{% for row in table %}
<p>{{row.name}}</p> // ...etc
{% endfor %}
{% endfor %}
I'm trying to pull multiple DBs onto one page via a module. I've written JS code to do this using the HubDB API, but I want to see if it's possible with HubL.
Possible to loop over multiple HubDBs in a module?
SOLVE
If anyone was curious or comes across this, item in this case is an object (although doesn't seem like one if you output it), so you need to use dot notation. All credit and thanks to @Jsum.
{% for item in module.hubdbtable %}
{% set table = hubdb_table_rows(item.id) %}
{% for row in table %}
<p>{{row.name}}</p>
// ...etc
{% endfor %}
{% endfor %}
Possible to loop over multiple HubDBs in a module?
SOLVE
If anyone was curious or comes across this, item in this case is an object (although doesn't seem like one if you output it), so you need to use dot notation. All credit and thanks to @Jsum.
{% for item in module.hubdbtable %}
{% set table = hubdb_table_rows(item.id) %}
{% for row in table %}
<p>{{row.name}}</p>
// ...etc
{% endfor %}
{% endfor %}