CMS Development

peesen
Contributor

Get row item.name in lowercase and withous spaces

SOLVE

Hello everyone

 

I need to get the values of a HubDB Multi-Select-Field and set all to lowercase and remove the spaces. How is this possible in HubSpot?

 

Thank you so much!

 

 {% for item in row.departments %}{{ item.name }}{% endfor %}"

 

0 Upvotes
1 Accepted solution
dbeau79
Solution
Contributor | Diamond Partner
Contributor | Diamond Partner

Get row item.name in lowercase and withous spaces

SOLVE

@peesen , happy to help... probably a prettier way to do this but this will work:

{{ row.departments|map('name')|join(',')|lower|replace(' ','-')|split(',')|join(' ') }}

View solution in original post

8 Replies 8
peesen
Contributor

Get row item.name in lowercase and withous spaces

SOLVE

@dbeau79  Yeah for sure. This is my loop:

 

{% set tableId = 'team' %}

{% if tableId %}
<div class="module-team" style="margin: 0 auto;">

  <div class="team_grid_wrapper" id="myTable">
          {% set queryparam = "&orderBy=lastname&orderBy=firstname" %}

          {% set table = hubdb_table_rows('team', queryparam) %}
          {% for row in table %}
            <div class="team_block {% for item in row.departments %}{{ item.name }}{% endfor %} TEST">
                <div class="team_img">
                  <span>Here comes the img</span>
                </div>
                <div class="team_text_wrapper">
                    <div class="team_text">                
                        <h3>{{ row.lastname }} {{ row.firstname }}</h3>
                    </div> 
                </div>
            </div> {# Team block #}
          {% endfor %}  
  </div> {# Team Grid Wrapper closed #}
</div>
{% endif %}  
0 Upvotes
dbeau79
Contributor | Diamond Partner
Contributor | Diamond Partner

Get row item.name in lowercase and withous spaces

SOLVE

Ah, try this:

 

{{ row.departments|map('name')|join(' ')|lower }}

 

(swapped "item" for "row")

peesen
Contributor

Get row item.name in lowercase and withous spaces

SOLVE

@dbeau79Thank you so much, the lowercase output is now working perfect! 🙂 But how can i remove the spaces inside the names? Thank you so much for all your help! I really appreciate it!

0 Upvotes
dbeau79
Solution
Contributor | Diamond Partner
Contributor | Diamond Partner

Get row item.name in lowercase and withous spaces

SOLVE

@peesen , happy to help... probably a prettier way to do this but this will work:

{{ row.departments|map('name')|join(',')|lower|replace(' ','-')|split(',')|join(' ') }}
peesen
Contributor

Get row item.name in lowercase and withous spaces

SOLVE

@dbeau79Oh wow! This Version is even better than what i thought with just removing the spaces. Thank you so much for your help! Have a nice evening!

0 Upvotes
dbeau79
Contributor | Diamond Partner
Contributor | Diamond Partner

Get row item.name in lowercase and withous spaces

SOLVE

@peesen , so you want to get this for each row, right?  Not all the options available in the column?  If so you could do it as follows:

{{ item.departments|map('name')|join(' ')|lower }} ... this would replace your for loop. 

0 Upvotes
peesen
Contributor

Get row item.name in lowercase and withous spaces

SOLVE

Hello @dbeau79 . Yes i need to get every row of the MultiSelect Field from the HubDB. When i replace my loop with your code i get no output. Can you please help me with more details?

0 Upvotes
dbeau79
Contributor | Diamond Partner
Contributor | Diamond Partner

Get row item.name in lowercase and withous spaces

SOLVE

@peesen , Can you drop in the code for your whole table loop?

0 Upvotes