Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Displaying Only Unique Topics in For Loop
Contributor
May 31, 2018 9:27 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content