Hi Hubspot community,
I believe this is a simple issue with the for loop statement I’m trying to do but I’m struggling to get the list of subjects to output. Can output fine until I turn on the repeater option. Any thoughts?
Thanks in advance.
<div class="container">
<button class="accordion">{{module.heading}}</button>
<div class=accordion-content style="padding-top:20px;">
<div>{{ module.text_above }}</div>
<div>{% for subject_page_url in module.subject.properties.subject_page_url %}{% for name in module.subject.properties.name %}<a href="{{ module.subject.properties.subject_page_url }}">{{ module.subject.properties.name }}</a>{% endfor %}{% endfor %}</div>
<div>{{ module.text_below }}</div>
</div>
</div>
Hi, @Luke-Simp
Thanks for reaching out! Hey, @alyssamwilie @Sjardo, do you have any experience or tips you can share with @Luke-Simp?
Thank you! — Jaycee
The screenshot doesn’t show the field names or the fields you have in Subject so not sure if this correctly references those fields but you want to loop through module.subject and access the url and name through the for loop item (subject) :
{% for subject in module.subject %}
<a href="{{ subject.properties.subject_page_url }}">
{{ subject.properties.name }}
</a>
{% endfor %}
If you’re in the design manager you can click Actions > Copy Snippet on a repeater group and it’ll copy to your clipboard a for loop of the group that you can then paste into your HTML.
Thanks for the solution and heads up about the copy snippet. A combination of both helped me to solve it. You’re a legend!