Does anyone know if it is possible to create a global control to change multiple modules in an email at once? Any guidance would be greatly appreciated.
Thank you for your post @SStrachan .
@miljkovicmisa and @Kevin-C , is this something you’re familiat with?
Hello @SStrachan , and thank you for writing,
hi @natsumimori, thanks for tagging,
This is definately possible as all the data from custom modules that is rendered in the template is accessible via the {{ content.widgets.name_of_module.body.parameter }} variable.
This means that if you create a module that pulls data from a hubdb row without outputting anything and add it to you template anywhere with a unique id, you can then create other modules that pull selectively data from that module with the above variable and render it on the page, this would look something like this in your case {{ content.widgets.name_of_module.body.hubdbrow_field.columns.name }} will output the name column of the selected yacht. This is extensively documented here in this link.
Note that the name_of_module is actually the unique id of the module in the template.
Note: I will be returning with a simple code example for this, I just don’t have enough time right now to code it. Hope the above gives you an idea of what is going on and hopefully with my little demo you’ll be able to achieve the result you need.
Thank you @miljkovicmisa !
I’ll take a stab at it. Some code examples would be a huge help.
I put together a basic example, but cant seem to get it to work.
You can see I dont get anything in the output. Once I understand the connection Ill better understand it.
Thanks @natsumimori
Hey @SStrachan
I’ve not done this with email but have experience on the web page side.
If all works in a similar way you can run an if on a hubdb value to the email
{% if hub_db_row_value = "1" %}
{# layout 1 #}
<h2>1</h2>
{% module "for_one" path="../somewhere1.module" %}
{% elif if hub_db_row = "2" %}
{# layout 2 #}
<h2>1</h2>
{% module "for_one" path="../somewhere2.module" %}
{% else %}
{# layout 3 #}
<h2>3</h2>
{% module "for_one" path="../somewhere3.module" %}
{% endif %}
Hope this gets ya going, and feel free to ask if anything comes up!
EDIT:
This does also work with DND module on web pages. I’d imagine the same for email.
Thanks for jumping in @Kevin-C
The email modules are slighly different. I’m still having some trouble with what code needs to go on my “parent module” and what code needs to go on my “child module”. Once I can get some output to the child module I’m sure I’ll understand the connection.
@SStrachan
Could you post the code you’ve got now?
Hello there @SStrachan ,
Seems like dnd areas in coded email templates is not supported at this time according to this document.
You can still achieve what you need but your template is not going to be drag and drop style.
If this is not of your concern and would still like to get the functionality you want it is achievable like so:
1. create a new email template in the design manager.
2. create a module that will hold the hubdb rows selector (you probably already got this).
3. create all the other modules that will hold the various fields from the selected row from previous module.
3.1 in each module for each item from the hubdb place this code that will output the data:
{{widget_data.yachts_module.hubdbrow_field.columns.yacht_details}}
the first part `widget_data` is all the data from all the modules that have export_to_template_context=True, the next `yachts_module` is the unique name of the module that we insert in step 4, the rest is self-explanatery, the last one `yacht_details` must correspond with the name of your column.
4. insert the code snippet of the module with the hubdb in it with the following code making the necessary replacements according to your snippet
{% module "yachts_module" path="/email-test-custom-module", label="email-test-custom-module", export_to_template_context=True %} this module doesn’t output anything so you can add it in the beginning or in the end…
You can find that snippet in the lower right of the module window
Finally add the rest of the modules inside the template where you would like the data to appear like you did in part 4. Be careful to add unique names for each module.
Hope my answer helped you although it’s a real bummer you cant code dnd areas for emails, nevertheless this should make your life easier and add consistency to your emails.
If you need any further assistance don’t hesitate to write. And also share your code of the template so I can be of more help.
If my answer helped you please mark it as a solution.
@miljkovicmisa Thats a bummer this wont work in a DnD template. Are there plans to integrate DnD?
@SStrachan indeed a bummer, though I’m optimistic that it will be available in the future because the doc says “at this time” and that means it’s prone to change.
You can also subscribe to the hubspot platform changelog in this link, where you can find all the past and upcoming changes on the hubspot platform, it’s most likely that such a change will be posted there.
Hope my answers were helpful to you, if so, mark it as a solution so others can find this info.
I have this working now. Quick question though. Can the modules that will be controled be hidden from the list since they have no controls? also can I move the picker module to the top of the list? See here.
I am getting some odd behavior with the data not refreshing. See here: Dropbox Capture
Trying to understand if this is a bug or something is wrong in my coding.
