Answers.Body: <p>Use a <a href="http://buildwithcraft.com/docs/templating/craft.entries#descendantOf" rel="nofollow"><code>descendantOf</code></a> parameter with a new ElementCriteriaModel instead of the <a href="http://buildwithcraft.com/docs/templating/entrymodel#getDescendants" rel="nofollow"><code>getDescendants</code></a> method on your entry model and you can add additional parameters. In your case add <code>cf_hideFromNav</code> as a parameter:</p>
  
  <pre><code>{% set topEntry = craft.entries.section('pages').slug('club').first() %}
  {% set navItems = craft.entries.section('pages').descendantOf(topEntry).cf_hideFromNav('0') %}
  
  {% nav navItem in navItems %}
      ...
  {% endnav %}
  </code></pre>
  
  <p>You could also use the parameters <a href="http://buildwithcraft.com/docs/templating/craft.entries#id" rel="nofollow"><code>id</code></a> or <a href="http://buildwithcraft.com/docs/templating/craft.entries#slug" rel="nofollow"><code>slug</code></a> to exclude certain entries:</p>
  
  <pre><code>{% set topEntry = craft.entries.section('pages').slug('club').first() %}
  {% set navItems = craft.entries.section('pages').descendantOf(topEntry).id('and, not 23, not 40, not 12') %}
  </code></pre>
  
  <p>The <a href="http://buildwithcraft.com/docs/templating/craft.entries#descendantOf" rel="nofollow"><code>descendantOf</code></a> parameter also takes IDs. This would allow you to do this all with just a single ElementCriteriaModel:</p>
  
  <pre><code>{% set navItems = craft.entries.section('pages').descendantOf('1').id('and, not 23, not 40, not 12') %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-27T14:50:50.273Z
Answers.Text: hi, that was exactly what I was after! but to my surprise it's not working!
Answers.UserDisplayName: outline4
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-27T14:51:38.357Z
Answers.Text: this works: {% set navItems = craft.entries.section('pages').descendantOf(topEntry).cf_hideFromNav('1') %} -> it only shows the navItems that should not be displayed... but the other way round it doesn't work... bug?
Answers.UserDisplayName: outline4
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-27T14:52:29.217Z
Answers.Text: but this works: {% set navItems = craft.entries.section('pages').descendantOf(topEntry).cf_hideFromNav('not 1') %} -> strange!
Answers.UserDisplayName: outline4
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-27T15:05:58.837Z
Answers.Text: Nice you got it working, @outline4! Lightswitches write `0` to the DB if not active, so it's in fact strange!
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-27T13:27:01.963Z
Answers.LastActivityDate: 2014-08-27T13:48:31.577Z
Answers.LastEditDate: 2014-08-27T13:48:31.577Z
Answers.UserDisplayName: carlcs
Body: <p>I am looking for a way to exclude certain pages from the navigation. I know it must be quite easy, but nothing seems to work for me at the moment. </p>
  
  <p>So I've setup a lightswitch field "exclude from navigation" (cf_hideFromNav)</p>
  
  <p>Problem is that I want the navigation to start only from a certain slug: </p>
  
  <pre><code>{% set topEntry = craft.entries.section('pages').depth(1).slug('club').first() %}
  {% set descendants = topEntry.getDescendants()  %}              
  &lt;ul&gt;
      {% nav entry in descendants %}
          &lt;li&gt;
              {{ entry.title }} 
              {% ifchildren %}&lt;ul&gt;{% children %}&lt;/ul&gt;{% endifchildren %}
          &lt;/li&gt;
      {% endnav %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>how could I incorporate the cf_hideFromNav in this equation?</p>
  
  <p>any help appreciated!<br>
  cheers<br>
  stefan</p>
  
Tags: <navigation>
Title: How to exclude a page from the navigation tree
ThreadText: # How to exclude a page from the navigation tree
  
  (Asked by: username_0 on 2014-08-27)
  
  I am looking for a way to exclude certain pages from the navigation. I know it must be quite easy, but nothing seems to work for me at the moment.
  
  So I've setup a lightswitch field "exclude from navigation" (cf\_hideFromNav)
  
  Problem is that I want the navigation to start only from a certain slug:
  
  ```
  {% set topEntry = craft.entries.section('pages').depth(1).slug('club').first() %}
  {% set descendants = topEntry.getDescendants()  %}              
  <ul>
      {% nav entry in descendants %}
          <li>
              {{ entry.title }} 
              {% ifchildren %}<ul>{% children %}</ul>{% endifchildren %}
          </li>
      {% endnav %}
  </ul>
  
  ```
  
  how could I incorporate the cf\_hideFromNav in this equation?
  
  any help appreciated!  
  cheers  
  stefan
  
  **Tags:** navigation
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-08-27. Score: 2 | Accepted answer
  
  Use a [`descendantOf`](http://buildwithcraft.com/docs/templating/craft.entries#descendantOf) parameter with a new ElementCriteriaModel instead of the [`getDescendants`](http://buildwithcraft.com/docs/templating/entrymodel#getDescendants) method on your entry model and you can add additional parameters. In your case add `cf_hideFromNav` as a parameter:
  
  ```
  {% set topEntry = craft.entries.section('pages').slug('club').first() %}
  {% set navItems = craft.entries.section('pages').descendantOf(topEntry).cf_hideFromNav('0') %}
  
  {% nav navItem in navItems %}
      ...
  {% endnav %}
  
  ```
  
  You could also use the parameters [`id`](http://buildwithcraft.com/docs/templating/craft.entries#id) or [`slug`](http://buildwithcraft.com/docs/templating/craft.entries#slug) to exclude certain entries:
  
  ```
  {% set topEntry = craft.entries.section('pages').slug('club').first() %}
  {% set navItems = craft.entries.section('pages').descendantOf(topEntry).id('and, not 23, not 40, not 12') %}
  
  ```
  
  The [`descendantOf`](http://buildwithcraft.com/docs/templating/craft.entries#descendantOf) parameter also takes IDs. This would allow you to do this all with just a single ElementCriteriaModel:
  
  ```
  {% set navItems = craft.entries.section('pages').descendantOf('1').id('and, not 23, not 40, not 12') %}
  
  ```
  
  > **Comments:**
  > **username_0**: hi, that was exactly what I was after! but to my surprise it's not working!  
  > **username_0**: this works: {% set navItems = craft.entries.section('pages').descendantOf(topEntry).cf_hideFromNav('1') %} -> it only shows the navItems that should not be displayed... but the other way round it doesn't work... bug?  
  > **username_0**: but this works: {% set navItems = craft.entries.section('pages').descendantOf(topEntry).cf_hideFromNav('not 1') %} -> strange!  
  > **username_1**: Nice you got it working, @username_0! Lightswitches write `0` to the DB if not active, so it's in fact strange!  
  
  ---
  
  