Currently, I am working in the HubSpot Design Manager, where I am fetching and rendering data. When I switch to the Design Previewer, I can see the rendered data, which works perfectly.
I have manually added a choice field from the “Add Fields” option and provided the required options. This field also renders correctly in the previewer.
What I want to achieve is that, by selecting any option from this choice field, the rendered data should change based on the selected option.
The challenge I am facing is how to access this featured select field in the Design Manager code because I need to use the value of this select field in my code.
Currently, I am using a hardcoded value in my code, as shown below:
{% if row[“13”] == “BMW” %}
If I can somehow access the value of the HubSpot featured select field, I can make this condition dynamic.
Hi, @RTeja Thanks for your post. Let’s invite some of our community members to the converstaion — hey @Anton@SteveHTM do you have a simple example you can share with @RTeja?
are you using HubDB? Just asking because “row” is pretty common when using HubDB. If you should use HubDB the markup should be like this:
{% if row[COLUMNNAME] == "an-input-from-HubDB" %}
lorem ipsum
{% elif row[COLUMNNAME] == "a-different-input-from-HubDB" %}
dolor set
{% endif %}
If you want to utilize plain module logic the markup should look like this:
{% if module.choice_field == "a-value-from-the-choice-option" %}
lorem ipsum
{% elif module.choice_field == "a-different-value-from-the-choice-option" %}
dolor set
{% endif %}
or
{% set my_custom_selector = module.choice_field %}
{% if my_custom_selector == "some-input" %}
lorem ipsum
{% elif mmy_custom_selector == "some-different-input" %}
dolor set
{% endif %}
(“choice_field” is the name of your choice field)
So in your case it could be:
{% if module.choice_field == "BMW" %}
Content if BMW is selected
{% elif module.choice_field == "Audi" %}
Content if Audi is selected
{% endif %}
Also - while you technically could access the values of the choice_field,I don’t recommend you to do so since you/HubSpot won’t really know when to show which information.