Answers.Body: <p>Craft has a <a href="http://buildwithcraft.com/docs/templating/filters#group" rel="nofollow"><code>group filter</code></a>, that does just that:</p>
  
  <pre><code>{% for stad, events in craft.entries.section('events') | group('stad') %}
      &lt;option value="{{ stad }}"&gt;{{ stad }}&lt;/option&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-28T16:35:54.093Z
Answers.LastActivityDate: 2015-02-28T16:35:54.093Z
Answers.UserDisplayName: Paul
Answers.Body: <p>As you are outputting the options, build an array of <code>stad</code> values and check for duplicates on each loop iteration. If the value does not exist in the array, add it to the array and print out the option. </p>
  
  <pre><code>{% set stad_array = [] %}
  
  {% for entry in craft.entries.section('events') %}
      {% if entry.stad not in stad_array %}
          {% set stad_array = stad_array|merge([entry.stad]) %}
          &lt;option value="{{entry.stad}}" name="{{ entry.stad }}"&gt;{{ entry.stad }}&lt;/option&gt;
      {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>Hope this helps!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-01T11:11:45.283Z
Answers.Text: Thanks for the reply :) However, the other option is easier
Answers.UserDisplayName: Evin Wijninga
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-01T16:04:08.840Z
Answers.Text: Agreed! Glad you found a solution :)
Answers.UserDisplayName: Aaron Berkowitz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-28T15:27:31.440Z
Answers.LastActivityDate: 2015-02-28T15:27:31.440Z
Answers.UserDisplayName: Aaron Berkowitz
Body: <p>For an event page I have the option to filter on cities and countries. Each event has entry fields in which the city and country, of which the values are outputted in a drop down list on the front end.</p>
  
  <p>As some events happen in the same country and city I have multipe values that are the same. Is there any chance to filter these values in Craft and output it only ones?</p>
  
  <pre><code>{% for entry in craft.entries.section('events') %}                      
      &lt;option value="{{entry.stad}}" name="{{ entry.stad }}"&gt;{{ entry.stad }}&lt;/option&gt;
  {% endfor %}
  </code></pre>
  
Tags: <entry><field><filter>
Title: How to check if entry field value is already outputted, and prevent it again?
ThreadText: # How to check if entry field value is already outputted, and prevent it again?
  
  (Asked by: username_0 on 2015-02-28)
  
  For an event page I have the option to filter on cities and countries. Each event has entry fields in which the city and country, of which the values are outputted in a drop down list on the front end.
  
  As some events happen in the same country and city I have multipe values that are the same. Is there any chance to filter these values in Craft and output it only ones?
  
  ```
  {% for entry in craft.entries.section('events') %}                      
      <option value="{{entry.stad}}" name="{{ entry.stad }}">{{ entry.stad }}</option>
  {% endfor %}
  
  ```
  
  **Tags:** entry, field, filter
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-02-28. Score: 3 | Accepted answer
  
  Craft has a [`group filter`](http://buildwithcraft.com/docs/templating/filters#group), that does just that:
  
  ```
  {% for stad, events in craft.entries.section('events') | group('stad') %}
      <option value="{{ stad }}">{{ stad }}</option>
  {% endfor %}
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2015-02-28. Score: 2
  
  As you are outputting the options, build an array of `stad` values and check for duplicates on each loop iteration. If the value does not exist in the array, add it to the array and print out the option.
  
  ```
  {% set stad_array = [] %}
  
  {% for entry in craft.entries.section('events') %}
      {% if entry.stad not in stad_array %}
          {% set stad_array = stad_array|merge([entry.stad]) %}
          <option value="{{entry.stad}}" name="{{ entry.stad }}">{{ entry.stad }}</option>
      {% endif %}
  {% endfor %}
  
  ```
  
  Hope this helps!
  
  > **Comments:**
  > **username_0**: Thanks for the reply :) However, the other option is easier  
  > **username_2**: Agreed! Glad you found a solution :)  
  
  ---
  
  