I'm trying to create a dropdown filter based off a custom field in channel entries.
{exp:channel:entries channel="events"}
{!-- Build the complete listing --}
{exp:stash:append name="listing"}
<li><a href="{title_permalink='events/detail'}">{title}</a></li>
{/exp:stash:append}
{!-- Build the dropdown filter options. This is what I want to contain unique values --}
{exp:stash:append name="locations"}
<option>{event_location}</option>
{/exp:stash:append}
{/exp:channel:entries}
<select>
{exp:stash:get name="locations"}
</select>
<ul>
{exp:stash:get name="listing"}
</ul>
This might output something like:
<select>
<option>USA</option>
<option>USA</option>
<option>Australia</option>
<option>Canada</option>
</select>
<ul>
<li><a href="...">First US Event</a></li>
<li><a href="...">Second US Event</a></li>
<li><a href="...">Australian Event</a></li>
<li><a href="...">Canadian Event</a></li>
</ul>
However, I want the values in the {exp:stash:get name="locations"}
to only be output once.
ie. USA once, not twice.
Is this possible?
Edit:
Turns out it does what I wanted on its own in the code I posted.
However my actual code had a {count}
variable thrown in for testing.
{exp:stash:append name="locations"}
<option>{count} - {event_location}</option>
{/exp:stash:append}
The {count}
made each row unique.