CMS Development

Raghavendra
Participant | Platinum Partner
Participant | Platinum Partner

How to combine the hubdb and selection field

SOLVE

in the below code in the place of Athletics i need to add selection field or choice field, but it is showing syntax error

 

<div class="sporteng-acs-outer">
<div class="pagecenter">
<div class="sporteng-acs-inner">
<div class="sporteng-acs-heading">
<h2>
{{ module.case_studies_heading }}
</h2>
</div>
{% set case_data = hubdb_table_rows(module.hubdbtable_field, 'sport_filter=Athletics&limit=3') %}
<div class="sporteng-acs-cards">
{% for data in case_data %}
<div class="sporteng-acs-repeater">
<div class="sporteng-acs-repeater-image" style="background:url('{{ data.sport_image.url }}');">

</div>
<div class="sporteng-acs-repeater-text-section">
<div class="sporteng-acs-repeater-title">
<h3>
{{ data.title }}
</h3>
</div>
<div class="sporteng-acs-repeater-overview">
{{ data.description }}
</div>
<div class="sporteng-acs-repeater-readmore">
<a href="{{ data.page_link }}">
Read more >>>
</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>

1 Accepted solution
piersg
Solution
Key Advisor

How to combine the hubdb and selection field

SOLVE

Like so:

{% set queryparam = '&sport_filter__in=' ~ module.sport_type ~ '&limit=3' %}
{% set case_data = hubdb_table_rows(module.hubdbtable_field, queryparam) %}

Where module.sport_type is the id of your selection field. Use capitalize filter e.g. "module.sport_type|capitalize" if you're not ensuring the values of the selection field are written in sentence case so they match the values from your HubDB.

View solution in original post

12 Replies 12
piersg
Solution
Key Advisor

How to combine the hubdb and selection field

SOLVE

Like so:

{% set queryparam = '&sport_filter__in=' ~ module.sport_type ~ '&limit=3' %}
{% set case_data = hubdb_table_rows(module.hubdbtable_field, queryparam) %}

Where module.sport_type is the id of your selection field. Use capitalize filter e.g. "module.sport_type|capitalize" if you're not ensuring the values of the selection field are written in sentence case so they match the values from your HubDB.

AM23
Participant | Platinum Partner
Participant | Platinum Partner

How to combine the hubdb and selection field

SOLVE

but it is not working for all data it is case sensitive.

 

0 Upvotes
piersg
Key Advisor

How to combine the hubdb and selection field

SOLVE

Yes, it is case sensitive

0 Upvotes
AM23
Participant | Platinum Partner
Participant | Platinum Partner

How to combine the hubdb and selection field

SOLVE

but in html how to make it incase sensitive

0 Upvotes
piersg
Key Advisor

How to combine the hubdb and selection field

SOLVE

You have to match your HubL output with the HubDB values. So if all your values are first letter capitalised only e.g. "Athletics" or "High jump" (sentence case), then do 

module.sport_type|capitalize

Depends how you've written your values in the HubDB.

0 Upvotes
AM23
Participant | Platinum Partner
Participant | Platinum Partner

How to combine the hubdb and selection field

SOLVE

is it works only for capitalize, it is not working for upper or lower case

 

0 Upvotes
piersg
Key Advisor

How to combine the hubdb and selection field

SOLVE

Then make the value of the "AFL" in the choice field "Afl" (the label can still be "AFL").

0 Upvotes
AM23
Participant | Platinum Partner
Participant | Platinum Partner

How to combine the hubdb and selection field

SOLVE

in some row the first 3 letter is in capital in that condition it is not working.

AM23_0-1679890233448.png

 

0 Upvotes
piersg
Key Advisor

How to combine the hubdb and selection field

SOLVE

Just match the values of the choice field in your custom module to the values in the HubDB, so specifically set the value to be "AFL" and it should work.

0 Upvotes
AM23
Participant | Platinum Partner
Participant | Platinum Partner

How to combine the hubdb and selection field

SOLVE

AM23_3-1679910193720.png

{% set queryparam = '&sport_filter=' ~ module.choice_field|capitalize|replace('_',' ')|replace('&','') ~ '&limit=3' %}
{% set case_data = hubdb_table_rows(module.hubdbtable_field, queryparam) %}

0 Upvotes
AM23
Participant | Platinum Partner
Participant | Platinum Partner

How to combine the hubdb and selection field

SOLVE

AM23_2-1679909781653.png

 

for Heigh lighted  it is not working. and replace is also not working for & and ()

 

AM23
Participant | Platinum Partner
Participant | Platinum Partner

How to combine the hubdb and selection field

SOLVE

Thank you its working..😊