We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Apr 14, 2021 7:58 AM
{% set sections = range(1, 9) %}
{% set layout = '["Banner", "Highlight Section", "Full Width Content", "Two Column Content", "CTA"]' %}
{% choice "sections_field" label="How many content modules?", value="1", choices="{{ sections }}", export_to_template_context='True' %}
{% for section in sections|split(',', widget_data.sections_field.value) %}
{% choice "layout_field" label="{{ 'Module number ' ~ loop.index }}", value="Choose a module", choices="{{ layout }}", export_to_template_context='True', unique_in_loop="True" %}
{% endfor %}
{% block modules %}
{% for widget in widget_data %}
{% if loop.index0 <= widget_data.sections_field.value %}
{% if widget.value == "Banner" %}
{% module "module_16183972633217" path="/Email/Modules/Banner_2021", label="{{ 'Banner ' ~ loop.index0 }}" no_wrapper="True" unique_in_loop="True" %}
{% elif widget.value == "Highlight Section" %}
{% module "module_161839738089114" path="/Email/Modules/Highlight Section_2021", label="{{ 'Highlight Section ' ~ loop.index0 }}" no_wrapper="True" unique_in_loop="True" %}
{% elif widget.value == "Full Width Content" %}
{% module "module_161839740102915" path="/Email/Modules/Full Width Content_2021", label="{{ 'Full Width Content ' ~ loop.index0 }}" no_wrapper="True" unique_in_loop="True" %}
{% elif widget.value == "Two Column Content" %}
{% module "module_161658827143752" path="/Email/Modules/Two Column Content_2021", label="{{ 'Two Column Content ' ~ loop.index0 }}" no_wrapper="True" unique_in_loop="True" %}
{% elif widget.value == "CTA" %}
{% module "module_161839735274213" path="/Email/Modules/CTA - Full Width_2021", label="{{ 'CTA ' ~ loop.index0 }}" no_wrapper="True" unique_in_loop="True" %}
{% endif %}
{% endif %}
{% endfor %}
{% endblock %}
Apr 16, 2021 9:11 AM
Its hard to debug when we can't see the template. What does widget_data|pprint yield?
Is there a feature missing in the email drag and drop editor that you're trying to compensate for with this email template? You might can make a custom email module that will work in the drag and drop editor for each missing feature, then leverage the DnD editor for things like "full width" and "two column" options.
If the above is not an option, I'd honestly put it all in one module and skip the multi-module/separate choice field route – but I say that not knowing how many fields each module has and how complicated each module is in your original template.
I like kudos almost as much as cake – a close second.
Apr 17, 2021 4:57 AM
@John that is the template - I'm extending it with other HTML and modules don't contain anything that does `export_to_template_context`.
Apr 16, 2021 10:25 AM - edited Apr 16, 2021 10:25 AM
The main features missing in the D&D editor is the lack of CSS control for things like dark mode, media queries, custom fonts and accessibility.
Adding non-inline CSS in the body is an absolute no no as Gmail will strip it out.
This doesn't really address the bug at hand, hopefully Hubspot can address this.
Apr 15, 2021 8:37 PM
Nope, can't figure this one out at all, anyone else see what's happening here? Am I missing something?
Apr 14, 2021 2:01 PM
The line below inside the for loop is skipping over anything not equal to "Banner". I think that may be the culprit.
{% if widget.value == "Banner" %}
I like kudos almost as much as cake – a close second.
Apr 14, 2021 4:25 PM
Wouldn't it go to the elif statements next?
Apr 14, 2021 4:32 PM
haha you're exactly right. The way the code was indented I just skipped over it. Sorry
You should pretty print widget_data. I have a feeling there are some extra modules in there that are getting skipped over. Looking at that data might give you some answers
{{ widget_data|pprint }}
I like kudos almost as much as cake – a close second.
Apr 14, 2021 5:21 PM
It looks like the issue occurs as soon as I choose to have more sections in sections_field (6 or above) than I have options in the layout variable (five choices).
Still investigating!
Apr 14, 2021 12:42 PM
Hey @stinhambo ,
Do you have a link to the template in the marketplace?
Wondering if he has a support email for things like this
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |
Apr 14, 2021 7:01 PM
No this is somethink I created myself for an email template.