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 %}
<body class="otherBodyClasses {{ bodyClass }}">
{% else %}
<body class="otherBodyClasses">
{% endif %}
<main class="page" role="main">
{% block content %}
{% endblock %}
</main>
</body>
Or with the ternary syntax:
<body class="otherBodyClasses {{ bodyClass is defined ? bodyClass }}">
.
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:
<body class="otherBodyClasses {{ bodyClass is defined and != '' ? bodyClass }}">