Answers.Body: <p>Try:</p>
  
  <pre><code>if craft.entries.section('aboutus').lightswitch_field('1')|length
  </code></pre>
  
  <p>If you want to check if it is "off" use:</p>
  
  <pre><code>if craft.entries.section('aboutus').lightswitch_field('not 1')|length
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-23T09:32:55.513Z
Answers.Text: This sadly does not work. Both returns true. Any other idea?
Answers.UserDisplayName: Jonathan Schiffner
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-23T18:09:23.850Z
Answers.Text: Updated my answer.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-22T17:17:48.370Z
Answers.LastActivityDate: 2016-03-23T18:09:14.537Z
Answers.LastEditDate: 2016-03-23T18:09:14.537Z
Answers.UserDisplayName: Brad Bell
Body: <p>For a menu I have to check if a <code>lightswitch</code> field is on or not. The menu is in an extra header file. I've tried:</p>
  
  <pre><code>{% if craft.entries.section('aboutus').lightswitch_field %}style="display: none;"{% else %} ... {% endif %}
  </code></pre>
  
  <p>but this always jumps into the <code>else</code> part.</p>
  
Tags: <templating><entries><lightswitch>
Title: Check in header file if lightswitch field is on
ThreadText: # Check in header file if lightswitch field is on
  
  (Asked by: username_0 on 2016-03-22)
  
  For a menu I have to check if a `lightswitch` field is on or not. The menu is in an extra header file. I've tried:
  
  ```
  {% if craft.entries.section('aboutus').lightswitch_field %}style="display: none;"{% else %} ... {% endif %}
  
  ```
  
  but this always jumps into the `else` part.
  
  **Tags:** templating, entries, lightswitch
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-03-22. Score: 1 | Accepted answer
  
  Try:
  
  ```
  if craft.entries.section('aboutus').lightswitch_field('1')|length
  
  ```
  
  If you want to check if it is "off" use:
  
  ```
  if craft.entries.section('aboutus').lightswitch_field('not 1')|length
  
  ```
  
  > **Comments:**
  > **username_0**: This sadly does not work. Both returns true. Any other idea?  
  > **username_1**: Updated my answer.  
  
  ---
  
  