Struggling to loop through multi-select options from HubDB
SOLVE
Hi - marketer more than a developer here. I'm having some problems with what I think should be a super basic for loop. I'm embedding a module that pulls the value of a dropdown-select column from a specified row:
But the below loop is printing absolutely nothing.
{% for product in widget_data.our_products.value %}
{{ product.name }} <br>
{% endfor %}
Is this potentially to do with the speechmarks in the key value pairs? I'm sure I'm doing something completely daft here but can't work out what it is. Any suggestions massively appreciated!
Meant to reply earlier but I was having a bit of trouble visualing what you're going for. I think I get it now. (Thanks for the poke @Jaycee_Lewis😁)
My guest would be that you can't achieve what you're going for with a text module (@hubspot/text). I haven't tested it out but I'd assume the text module just spits it out as a string of text, so you can't itterate through it like an array.
What I'd suggest doing instead is creating a custom module, that's be something like:
{% set product_list = hubdb_table_row('quote_breakdown_pages', lookuprow).our_products %}
{% for product in product_list %}
{{ product.name }} <br>
{% endfor %}
Then just include the module in your template where you need it. Unless I'm overlooking something (i.e. what it "export_to_template_context=True" is being used for.
Or you might not even need a custom module if the above code could be put directly in your template.
If I've totally missed the mark let me know and if possible provide the full template.
Meant to reply earlier but I was having a bit of trouble visualing what you're going for. I think I get it now. (Thanks for the poke @Jaycee_Lewis😁)
My guest would be that you can't achieve what you're going for with a text module (@hubspot/text). I haven't tested it out but I'd assume the text module just spits it out as a string of text, so you can't itterate through it like an array.
What I'd suggest doing instead is creating a custom module, that's be something like:
{% set product_list = hubdb_table_row('quote_breakdown_pages', lookuprow).our_products %}
{% for product in product_list %}
{{ product.name }} <br>
{% endfor %}
Then just include the module in your template where you need it. Unless I'm overlooking something (i.e. what it "export_to_template_context=True" is being used for.
Or you might not even need a custom module if the above code could be put directly in your template.
If I've totally missed the mark let me know and if possible provide the full template.
Struggling to loop through multi-select options from HubDB
SOLVE
Thanks so much @BarryGrennan - yes I've ended up going for a module level solution here rather than getting it to work at a global level. Appreciate your help!
Struggling to loop through multi-select options from HubDB
SOLVE
Hey, @tmitch_sona👋 Thanks for reaching out. Please note, there is no technical (or otherwise) gatekeeping here, ALL are welcome to post, share and learn.