Answers.Body: <p>The solution is to <code>getEntryTypes()</code> from your section and then access the <code>getFieldLayout()</code> to get to the <code>getFields()</code> (thanks again @Khalwat!). Example:</p>
  
  <pre><code>{% for section in sections %}
      {% if section.getEntryTypes()[0].getFieldLayout().getFields()[0].getField().handle == 'specificfield' %}
          do something
      {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>Notice though that I specifically search for the first occurances, in (most) other cases you should <code>foreach</code> the <code>getEntryTypes()</code> and <code>getFields()</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-25T14:25:35.587Z
Answers.LastActivityDate: 2016-02-25T14:25:35.587Z
Answers.UserDisplayName: chris
Body: <p>For a plugin, I need to check if a certain field exists in a section. How can i manage that? I'm using the settings section from the plugin, looping through all sections by <code>craft()-&gt;sections-&gt;getAllSections()</code> and in the template with the following code:</p>
  
  <pre><code>{% for section in sections %}
      {% if section['specificfield'] is not defined %}
          do something
      {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>This doesn't seem to be working. Any ideas on how to check correctly?</p>
  
Tags: <sections>
Title: How can you check if a field exists in a section, not by entry?
ThreadText: # How can you check if a field exists in a section, not by entry?
  
  (Asked by: username_0 on 2016-02-25)
  
  For a plugin, I need to check if a certain field exists in a section. How can i manage that? I'm using the settings section from the plugin, looping through all sections by `craft()->sections->getAllSections()` and in the template with the following code:
  
  ```
  {% for section in sections %}
      {% if section['specificfield'] is not defined %}
          do something
      {% endif %}
  {% endfor %}
  
  ```
  
  This doesn't seem to be working. Any ideas on how to check correctly?
  
  **Tags:** sections
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-02-25. Score: 3 | Accepted answer
  
  The solution is to `getEntryTypes()` from your section and then access the `getFieldLayout()` to get to the `getFields()` (thanks again @Khalwat!). Example:
  
  ```
  {% for section in sections %}
      {% if section.getEntryTypes()[0].getFieldLayout().getFields()[0].getField().handle == 'specificfield' %}
          do something
      {% endif %}
  {% endfor %}
  
  ```
  
  Notice though that I specifically search for the first occurances, in (most) other cases you should `foreach` the `getEntryTypes()` and `getFields()`
  
  
  ---
  
  