0

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.

1

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
| improve this answer | |
  • This sadly does not work. Both returns true. Any other idea? – Jonathan Schiffner Mar 23 '16 at 9:32
  • Updated my answer. – Brad Bell Mar 23 '16 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.