title: Umbraco & Razor: If CurrentPage/Model is a Child, condition
body: <p>My navigation/node structure is as follows:</p>
  
  <p>Home<br>
  --About us<br>
  --Our Services<br>
  -----Finance<br>
  -----Insurance<br></p>
  
  <p>My current code loops through the nodes and lists them in an . When the 'CurrentPage' has children, the menu includes the children.</p>
  
  <p>The problem with this loop is that when one of those children (Finance or Insurance) is the 'CurrentPage', the 'if' condition on 'Our Services' node fails as th CurrentPage no longer has children, therefore 'Finance' and 'Insurance' now longer remain in the menu.</p>
  
  <p>I want to add to me 'if', an '||' clause which would basically say 'or CurrentPage is a child node'</p>
  
  <p>Code below
  thanks</p>
  
  <pre><code>&lt;ul&gt;
      @foreach (var page in @CurrentPage.AncestorOrSelf(1).Children)
      {
          &lt;li class="menuItems @(page.IsAncestorOrSelf(CurrentPage) ? "selected" : null)"&gt;
              &lt;a href="@page.Url"&gt;@page.Name test&lt;/a&gt;
          &lt;/li&gt;
  
  
          if (@CurrentPage.Children.Count() &gt; 0)
          {                
              foreach (var childPage in page.Children)
              {                    
                  &lt;li class="menuItems menuChildItems @(childPage.IsAncestorOrSelf(CurrentPage) ? "selected" : null)"&gt;
                      &lt;a href="@childPage.Url"&gt;@childPage.Name&lt;/a&gt;
                  &lt;/li&gt;
              }
          }
  
      }
  &lt;/ul&gt;
  </code></pre>