CMS Development

vperoza
Participant | Diamond Partner
Participant | Diamond Partner

Combine HubDB results and filter.

SOLVE

I'm pulling data from 3 separate HubDB tables and combining them into one data set, like so: 

 

{% set tbl1 = hubdb_table_rows(123) %}
{% set tbl2 = hubdb_table_rows(456) %}
{% set tbl3 = hubdb_table_rows(789) %}


{% set all_tbls = (tbl1 + tbl2 + tbl3) %}

 

I'd like to sort all_tbls by the NAME  field that exists in all of the tables.

 

I have tried using the |sort filter when combining the results:

{% set all_tbls = (basic_rows + video_rows + webinar_rows)|sort('hs_name') %}

 

And I tried different references to the field (hs_name, name, NAME, Name)

 

I have tried using the |sort filter within the "for" statement:

 

{% for row in all_tbls|sort('name') %}
{{ row.name }}
{% endfor %}

 

Neither seems to work and I cannot find documentation on this. 

Does anyone know how to sort the combined results?

0 Upvotes
1 Accepted solution
vperoza
Solution
Participant | Diamond Partner
Participant | Diamond Partner

Combine HubDB results and filter.

SOLVE

I just solved my own problem, so I'm sharing it here. This is the solution: 

 

{% for row inall_tbls|sort(false, false, 'name') %}

{{ row.name }}

{% endor %}

View solution in original post

1 Reply 1
vperoza
Solution
Participant | Diamond Partner
Participant | Diamond Partner

Combine HubDB results and filter.

SOLVE

I just solved my own problem, so I'm sharing it here. This is the solution: 

 

{% for row inall_tbls|sort(false, false, 'name') %}

{{ row.name }}

{% endor %}