CMS Development

cives
Contributor

HubDB filter

SOLVE

If I want to execute a code block differently depending on HubDB input, is this the right approach?


I have a hubdb checkbox column called “external”

 

 

{% for row in hubdb_table_rows('2620345', "&orderBy=date&visible=true") %}

{% if row.external = null %}

[code 1 here]

{% else %}

[code 2 here]

{% endif %}
{% endfor %}

 



The line {% if row.external = null %} is not filtering the data correctly.

 

Do I have that formatted wrong?

 

If external is checked off, I'd like to make alterations to the code, changing the functionality.

0 Upvotes
1 Accepted solution
evaldas
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

HubDB filter

SOLVE

Hi @cives,

 

If you are trying to set logic based on a checkbox value in HubDB, you can try updating your code to have the following:

 

{% if row.external == 0 %}

 

Note that you want to use the double equal sign "==" as the single is typically used to assign a value to a variable. The "external" should return either a 1 or 0 to reflect true/false.

 


 

Did my post help answer your query? Help the community by marking it as a solution.


✔️ Did this post help answer your query? Help the community by marking it as a solution.

View solution in original post

0 Upvotes
2 Replies 2
evaldas
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

HubDB filter

SOLVE

@cives  Alternatively, you can also use the following:

 

 

{% for row in hubdb_table_rows('2620345', "&orderBy=date&visible=true") %}

{% if !row.external %}

[code 1 here]

{% else %}

[code 2 here]

{% endif %}
{% endfor %}

 

 


✔️ Did this post help answer your query? Help the community by marking it as a solution.

0 Upvotes
evaldas
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

HubDB filter

SOLVE

Hi @cives,

 

If you are trying to set logic based on a checkbox value in HubDB, you can try updating your code to have the following:

 

{% if row.external == 0 %}

 

Note that you want to use the double equal sign "==" as the single is typically used to assign a value to a variable. The "external" should return either a 1 or 0 to reflect true/false.

 


 

Did my post help answer your query? Help the community by marking it as a solution.


✔️ Did this post help answer your query? Help the community by marking it as a solution.

0 Upvotes