I’m struggling to have a marketing email module to set a choice field option that is part of the module based on a client’s property value. Below example is if the contact’s custom property of “primarymarket” value is “KA”, then set the module choice field option to “new” otherwise set to “old”. The module field variable name is “logo_version” with options of “old” or “new”.
{% if contact.primarymarket == ‘KA’ %}
{% set module.logo_version = “new” %}
{% else %}
{% set module.logo_version = “old” %}
{% endif %}
for what I understand is that you’d like to change the logo based on the primarymarket property, right?
If so, you don’t need the choice field in the module. You can do it like this:
{% if contact.primarymarket == 'KA' %}
{% set logo_path = "PATH/TO/NEW/LOGO.jpg" %}
{% set logo_alt = module.new_logo_alt_text %} {# this is a simple text #}
{% else %}
{% set logo_path = "PATH/TO/old/LOGO.jpg" %}
{% set logo_alt = module.old_logo_alt_text %} {# this is a simple text #}
{% endif %}
...
<img src="{{ logo_path }}" alt="{{ logo_alt }}">
best,
Anton
edit: If you’re working with brandkits you can do it like this:
{% if contact.primarymarket == 'KA' %}
{% set logo_path = brand_settings.primaryLogo.src %}
{% set logo_alt = brand_settings.primaryLogo.alt %}
{% else %}
{% set logo_path = brand_settings.logos[2].src %} {# logos[1] is the same is primaryLogo #}
{% set logo_alt = brand_settings.logos[2].alt %}
{% endif %}
...
<img src="{{ logo_path }}" alt="{{ logo_alt }}">
Thanks for the response! The module is already pulling in the market logo (that is stored in a HubDB table) based on the contact property. Right now we are going through a style redesign and I need the module to have different (new) styling for certain markets during a gradual rollout. I’ve already got the module to change the style based on if a choice field in the module is manually set to “new” vs “old”. However, I need the module to dynamically be set to “new” or “old” based on the contact’s primary market. Is there a way to tell the module to dynamically change the field value to “new” if contact’s primary market is a certain value? Here is the logo_version choice field in the module: