CMS Development

ziadi
Contributor

pulling data from multiple columns HubDB HubL

SOLVE

Hello all, 

 

I want to combine dataasets from two columns from a hubDB table and pull the data into a filter. Here is a part of the code that I am using below:

<div id="container">
    {% set table = hubdb_table_rows(2034103) %}
    {% for row in table %}
    <div class="item {% for category in row.filter_item %}{{ category.name|lower|replace('|', '_')|replace('.', '')|replace('/', '_')|replace(' ', '_') }} {% endfor %}">
      <div class="item-inner">
        <h3>{{ row.Name }}</h3>
        <div class="grid-descr">
          {{ row.content }}
        </div>
        <a href="{{ row.button_link }}" target="_blank" class="learn_more_btn">Learn More</a>
      </div>
    </div>
    {% endfor %}
  </div>
</div>

I tried the following for this specific snippet (changes shown in red):

 <div class="item {% for category in (row.filter_item or row.molecule_class) %}{{ category.name|lower|replace('|', '_')|replace('.', '')|replace('/', '_')|replace(' ', '_') }} {% endfor %}">

because I wanted to combine the two columns and pull data from both columns.. but it doesn't seem to be working for me for some reason. Am I doing anything wrong? Is this the correct way to combine columns?

 

Thanks!

0 Upvotes
1 Accepted solution
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

pulling data from multiple columns HubDB HubL

SOLVE

Hey @ziadi 

 

If you're just looking to template that class in couldn't you just use 2 separate loops?

Something like this:

<div class="item {% for category in row.filter_item %}{{ category.name|lower|replace('|', '_')|replace('.', '')|replace('/', '_')|replace(' ', '_') }} {% endfor %} {% for category in row.molecule_class %}{{ category.name|lower|replace('|', '_')|replace('.', '')|replace('/', '_')|replace(' ', '_') }} {% endfor %}">

 

Kevin Cornett - Sr. Solutions Architect @ BridgeRev

View solution in original post

0 Upvotes
3 Replies 3
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

pulling data from multiple columns HubDB HubL

SOLVE

Hey @ziadi 

 

If you're just looking to template that class in couldn't you just use 2 separate loops?

Something like this:

<div class="item {% for category in row.filter_item %}{{ category.name|lower|replace('|', '_')|replace('.', '')|replace('/', '_')|replace(' ', '_') }} {% endfor %} {% for category in row.molecule_class %}{{ category.name|lower|replace('|', '_')|replace('.', '')|replace('/', '_')|replace(' ', '_') }} {% endfor %}">

 

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
0 Upvotes
ziadi
Contributor

pulling data from multiple columns HubDB HubL

SOLVE

Ah that just might be the missing link, i will try that! I am not very familiar with HubL or HubDB... appreciate the feedback!

sharonlicari
Community Manager
Community Manager

pulling data from multiple columns HubDB HubL

SOLVE

Hey @ziadi 

 

Thank you for the information provided. I'll tag a few experts Emoticono feliz

 

Hey @Dennis-DWFB @DanielSanchez @Anonymous  do you have any thoughts you'd like to share with @ziadi 

 

Thank you

Sharon


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Upvotes