Answers.Body: <p>This line:</p>
  
  <pre><code>{% set hideMenu = craft.entries.section('mysection').showMainNavigation('not 1').one() %} 
  </code></pre>
  
  <p>will return the first entry that it can find in the section 'mysection' that has <code>showMainNavigation</code> off. So as soon as you disable it for one entry, <code>hideMenu</code> will 'return' true, whichever page you're on.</p>
  
  <p>So to fix this, if <code>mainEntry</code> is your current entry, then replace the line by:</p>
  
  <pre><code>{% set hideMenu = mainEntry.showMainNavigation %} 
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-19T19:36:10.300Z
Answers.Text: Wow, I was really overthinking this! mainEntry is not the current entry but I used your example to fix this. {% set showMenu = entry.showMainNavigation %} then {% if not showMenu%}hide navigation{% else %}show navigation.
Answers.UserDisplayName: user9494
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-19T18:31:36.363Z
Answers.LastActivityDate: 2019-11-19T18:31:36.363Z
Answers.UserDisplayName: Seb
Body: <p>I am looking to hide the main navigation for entries that have the lightswitch 'showMainNavigation' disabled. The problem I am facing is when I disable for one entry, the navigation is hidden for all entries. Here is a sample of the code:</p>
  
  <pre><code>{% set mainEntry = craft.entries.slug(craft.app.request.getSegment(1)).one() %}
  {% set menuLogo = mainEntry.menuLogo %}
  {% set hideMenu = craft.entries.section('mysection').showMainNavigation('not 1').one() %} 
  
  {% if hideMenu %}
  &lt;nav class="navbar navbar-expand-lg main-menu"&gt;
      &lt;div class="standard-wrapper"&gt;
          {% if menuLogo|length %}
          &lt;div class="navbar-brand logo logo-white visible"&gt;&lt;a href="#"&gt;&lt;img src="{{siteUrl}}{{menuLogo.one().getUrl()}}"/&gt;&lt;/a&gt;&lt;/div&gt;
          {% endif %}
      &lt;/div&gt;
  &lt;/nav&gt;
  
  {% else %}
  
  &lt;nav class="navbar navbar-expand-lg main-menu"&gt;
      &lt;div class="standard-wrapper"&gt;
          {% if menuLogo|length %}
          &lt;div class="navbar-brand logo logo-white visible"&gt;&lt;a href="#"&gt;&lt;img src="{{siteUrl}}{{menuLogo.one().getUrl()}}"/&gt;&lt;/a&gt;&lt;/div&gt;
          {% endif %}
          &lt;button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" onclick="myFunction(this)"&gt;
              &lt;span class="navbar-toggler-icon"&gt;
              &lt;div class="bar1"&gt;&lt;/div&gt;
              &lt;div class="bar2"&gt;&lt;/div&gt;
              &lt;div class="bar3"&gt;&lt;/div&gt;&lt;/span&gt;
          &lt;/button&gt;
  
          &lt;div class="collapse navbar-collapse float-right menu" id="navbarSupportedContent"&gt;
              &lt;ul class="navbar-nav mr-auto no-list-style"&gt;
                  &lt;li class="nav-item active"&gt;list item 1&lt;/li&gt;
                  &lt;li class="nav-item active"&gt;list item 2&lt;/li&gt;
              &lt;/ul&gt;
           &lt;/div&gt;
       &lt;/div&gt;
  &lt;/nav&gt;
  {% endif %}
  </code></pre>
  
Tags: <craft3><lightswitch>
Title: Hide navigation from one entry but not others
ThreadText: # Hide navigation from one entry but not others
  
  (Asked by: username_0 on 2019-11-19)
  
  I am looking to hide the main navigation for entries that have the lightswitch 'showMainNavigation' disabled. The problem I am facing is when I disable for one entry, the navigation is hidden for all entries. Here is a sample of the code:
  
  ```
  {% set mainEntry = craft.entries.slug(craft.app.request.getSegment(1)).one() %}
  {% set menuLogo = mainEntry.menuLogo %}
  {% set hideMenu = craft.entries.section('mysection').showMainNavigation('not 1').one() %} 
  
  {% if hideMenu %}
  <nav class="navbar navbar-expand-lg main-menu">
      <div class="standard-wrapper">
          {% if menuLogo|length %}
          <div class="navbar-brand logo logo-white visible"><a href="#"><img src="{{siteUrl}}{{menuLogo.one().getUrl()}}"/></a></div>
          {% endif %}
      </div>
  </nav>
  
  {% else %}
  
  <nav class="navbar navbar-expand-lg main-menu">
      <div class="standard-wrapper">
          {% if menuLogo|length %}
          <div class="navbar-brand logo logo-white visible"><a href="#"><img src="{{siteUrl}}{{menuLogo.one().getUrl()}}"/></a></div>
          {% endif %}
          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" onclick="myFunction(this)">
              <span class="navbar-toggler-icon">
              <div class="bar1"></div>
              <div class="bar2"></div>
              <div class="bar3"></div></span>
          </button>
  
          <div class="collapse navbar-collapse float-right menu" id="navbarSupportedContent">
              <ul class="navbar-nav mr-auto no-list-style">
                  <li class="nav-item active">list item 1</li>
                  <li class="nav-item active">list item 2</li>
              </ul>
           </div>
       </div>
  </nav>
  {% endif %}
  
  ```
  
  **Tags:** craft3, lightswitch
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-11-19. Score: 2 | Accepted answer
  
  This line:
  
  ```
  {% set hideMenu = craft.entries.section('mysection').showMainNavigation('not 1').one() %} 
  
  ```
  
  will return the first entry that it can find in the section 'mysection' that has `showMainNavigation` off. So as soon as you disable it for one entry, `hideMenu` will 'return' true, whichever page you're on.
  
  So to fix this, if `mainEntry` is your current entry, then replace the line by:
  
  ```
  {% set hideMenu = mainEntry.showMainNavigation %} 
  
  ```
  
  > **Comments:**
  > **username_0**: Wow, I was really overthinking this! mainEntry is not the current entry but I used your example to fix this. {% set showMenu = entry.showMainNavigation %} then {% if not showMenu%}hide navigation{% else %}show navigation.  
  
  ---
  
  