Two different lightswitches to add class on body tag I'm using a lightswitch field to add a class to my html document body-tag. The field is added to a section  with a handle named "events". 

To make this happen, I do this in my _layout.html:

{% if entry.whiteLogoText %}
    &lt;body class="white"&gt;
{% else %}
    &lt;body&gt;
{% endif %}


Now I also want to use such a lightswitch for entries of a different section (with a field handle named 'projects').

Should I make a new lightswitch field for this particular section, and if so, how should I print it?

I wanna make sure I don't get two &lt;body&gt;-tags.
You can use the same lightswitch field on both of your channel sections.

But I wouldn't use an EntryModel in the _layout.html (assuming that's a template you use to extend your actual entry and index templates with).

You probably have two different _entry.html templates for your sections "project" and "events". Define a variable in these if your condition (lightswitch) is true:



{% extends "_layout" %}

{% if entry.whiteLogoText %}
    {% set bodyClass = 'white' %}
{% endif %}

{% block content %}
{% endblock %}


This is how your _layout.html should look like:

{% if bodyClass is defined %}
    &lt;body class="otherBodyClasses {{ bodyClass }}"&gt;
{% else %}
    &lt;body class="otherBodyClasses"&gt;
{% endif %}

&lt;main class="page" role="main"&gt;
    {% block content %}
    {% endblock %}
&lt;/main&gt;

&lt;/body&gt;


Or with the ternary syntax:

&lt;body class="otherBodyClasses {{ bodyClass is defined ? bodyClass }}"&gt;


.

Edit:

You can additionally set that bodyClass variable in other templates using different conditionals:

{% if myGlobalSetHandle.whiteLogoTextForProjectsEntries %}
    {% set bodyClass = 'white' %}
{% endif %}


or (based on my latest assumptions on what you wanna do):

{# Define var before the for loop #}
{% set bodyClass = '' %}

{# Check if `whiteLogoText` is set on any "project" entry #}
{% for project in craft.entries.section('projects') %}
    {% if project.whiteLogoText %}
        {% set bodyClass = 'white' %}
    {% endif %}
{% endfor %}


With this last code example you have to define the variable before the loop to make it accessible outside of it. Because you will always have a bodyClass defined then, change the conditional in your _layout.html like this:

&lt;body class="otherBodyClasses {{ bodyClass is defined and != '' ? bodyClass }}"&gt;