Answers.Body: <p>This can be done by reaching through the section and entry type to the final field layout. Like this:</p>
  
  <pre><code>{% set section = craft.sections.getSectionByHandle('sectionName') %}
  {% set entryType = '' %}
  {% for type in section.getEntryTypes %}
      {% if type.handle == 'entryType' %}
          {% set entryType = type %}
      {% endif %}
  {% endfor %}
  {% set fieldLayout = craft.fields.getLayoutById(entryType.fieldLayoutId) %}
  </code></pre>
  
  <p>You should be abel to use <code>getFields</code> as normal.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-22T20:10:24.227Z
Answers.Text: Worked like a charm! Thanks. I'm glad I asked. It would have taken me forever (or possibly never) to figure that out on my own.
Answers.UserDisplayName: Philip Jones
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-22T19:58:42.813Z
Answers.LastActivityDate: 2016-02-22T19:58:42.813Z
Answers.UserDisplayName: Bryan Redeagle
Body: <p>Is there a way in a template to loop through the fields in a field layout without having to tie them to an entry? I'm currently grabbing that list with <code>entry.getFieldLayout(3).getFields()</code>, but that only works when <code>entry</code> is set.</p>
  
Tags: <templating><field><loop>
Title: Loop through fields in field layout when `entry` is not set
ThreadText: # Loop through fields in field layout when `entry` is not set
  
  (Asked by: username_0 on 2016-02-22)
  
  Is there a way in a template to loop through the fields in a field layout without having to tie them to an entry? I'm currently grabbing that list with `entry.getFieldLayout(3).getFields()`, but that only works when `entry` is set.
  
  **Tags:** templating, field, loop
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-02-22. Score: 2 | Accepted answer
  
  This can be done by reaching through the section and entry type to the final field layout. Like this:
  
  ```
  {% set section = craft.sections.getSectionByHandle('sectionName') %}
  {% set entryType = '' %}
  {% for type in section.getEntryTypes %}
      {% if type.handle == 'entryType' %}
          {% set entryType = type %}
      {% endif %}
  {% endfor %}
  {% set fieldLayout = craft.fields.getLayoutById(entryType.fieldLayoutId) %}
  
  ```
  
  You should be abel to use `getFields` as normal.
  
  > **Comments:**
  > **username_0**: Worked like a charm! Thanks. I'm glad I asked. It would have taken me forever (or possibly never) to figure that out on my own.  
  
  ---
  
  