CMS Development

tstrack
Colaborador(a) | Parceiro Platinum
Colaborador(a) | Parceiro Platinum

Displaying Only Unique Topics in For Loop

I'm using a for loop to gather topics from all blog posts and populate those topics in a select element. I'm currently seeing duplicates due to the same topics across multiple blog posts. Here is my code:

<!-- Services Filter -->
<select class="select-filter" data-filter-group="services">
  <option value="*">Services</option>
  {% for content in contents %}
  {% for topic in content.topic_list %}
  <option value=".filter-{{ topic.name|lower|replace(' ','-') }}">{{ topic.name }}</option>
  {% endfor %}
  {% endfor %}
</select>

I see that there is a HubL filter for unique. I tried a few things but didn't have any luck. How would I incorporate the unique filter so there are no duplicate topics in my select element?

0 Avaliação positiva
1 Resposta 1
roisinkirby
Equipe de Produto da HubSpot
Equipe de Produto da HubSpot

Displaying Only Unique Topics in For Loop

Hey @tstrack could you share a link to the page(s) you are working on? @dessery is this something you have acheived before?

0 Avaliação positiva