Answers.Body: <p>Sometimes you need the same parent/siblings menu from various POVs (parent or children). Here's what I came up with:</p>
  
  <pre><code>{# Parent / Children subnavigation, either from the perspective of the parent or a child #}
  
  {% if entry.level == 1 %}
    {% set parent = entry %}
    {% set children = entry.getDescendants().all() %}
  {% elseif entry.level == 2 %}
    {% set parent = entry.getAncestors().one() %}
    {% set children = entry.getSiblings().all() %}
  {% endif %}
  
  &lt;h1&gt;&lt;a href="{{parent.url}}"&gt;{{parent.title}}&lt;/a&gt;&lt;/h1&gt;
  &lt;ul&gt;
      {% for child in children %}
      &lt;li&gt;&lt;a href="{{child.url}}"&gt;{{child.title}}&lt;/a&gt;&lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>I wonder if that's a detour and there's an easier way?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-03T09:30:58.450Z
Answers.LastActivityDate: 2018-09-03T09:30:58.450Z
Answers.UserDisplayName: Urs
Answers.Body: <p>For this you should be able to use the getSibling() method which:</p>
  
  <p>"Returns an ElementCriteriaModel object prepped to return the entry’s siblings (if it lives in a Structure section)."</p>
  
  <p><a href="https://docs.craftcms.com/v2/templating/entrymodel.html#getsiblings" rel="nofollow noreferrer">https://docs.craftcms.com/v2/templating/entrymodel.html#getsiblings</a></p>
  
  <pre><code>{% set siblings = entry.getSiblings().all() %}
  
  &lt;ul&gt;
      {% for page in siblings %}
          &lt;li class="item-contentmenu"&gt;
              &lt;a href="{{ page.url }}"&gt;{{ page.title }}&lt;/a&gt;
          &lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-30T11:13:35.333Z
Answers.Text: I've tried this instead of the code below but with no success again the model returns Null for siblings. Any ideas why?
Answers.UserDisplayName: Lettie
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-30T16:51:10.500Z
Answers.Text: could you show how you tried to implement the getSibling()? But to note it wont really improve on the answer you've given.
Answers.UserDisplayName: George D
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2015-07-30T10:19:14.630Z
Answers.LastActivityDate: 2018-09-06T18:38:49.947Z
Answers.LastEditDate: 2018-09-06T18:38:49.947Z
Answers.UserDisplayName: George D
Answers.Body: <p>Ok I've worked this out from above and adding some other code and now it works as below:</p>
  
  <pre><code>{% set parent = entry.getAncestors().first() %}
  {% for subnav in craft.entries.section('mySection').descendantOf(parent).descendantDist('1') %}
      &lt;li&gt;&lt;a href="{{ subnav.url }}"&gt;{{ subnav.title }}&lt;/a&gt;&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
  <p>Hope this assists someone else.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-30T11:23:42.730Z
Answers.LastActivityDate: 2015-07-30T11:23:42.730Z
Answers.UserDisplayName: Lettie
Body: <p>I have a structure as follows:</p>
  
  <ul>
  <li>Parent 1
  
  <ul>
  <li>Child 1</li>
  <li>Child 2</li>
  <li>Child 3</li>
  </ul></li>
  <li>Parent 2
  
  <ul>
  <li>Child 1</li>
  <li>Child 2</li>
  <li>Child 3</li>
  </ul></li>
  <li>Parent 3
  
  <ul>
  <li>Child 1</li>
  <li>Child 2</li>
  <li>Child 3
  etc...</li>
  </ul></li>
  </ul>
  
  <p>On my Child entry pages I want to pull out the other child entries under that parent to use as navigation. I think this should be fairly straight forward but I can not find any documentation on it. So far I have the below but this pulls out all level 2 child entries and not just the entries for the specified parent.</p>
  
  <p>Any help much appreciated.</p>
  
  <pre><code>{% for subnav in craft.entries.section('mySection').level(2).find() %}
      &lt;li&gt;&lt;a href="{{ subnav.url }}"&gt;{{ subnav.title }}&lt;/a&gt;&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
Tags: <structure><navigation>
Title: How do you pull out second level structure entries based on their parent?
ThreadText: # How do you pull out second level structure entries based on their parent?
  
  (Asked by: username_0 on 2015-07-30)
  
  I have a structure as follows:
  
  * Parent 1
    + Child 1
    + Child 2
    + Child 3
  * Parent 2
    + Child 1
    + Child 2
    + Child 3
  * Parent 3
    + Child 1
    + Child 2
    + Child 3
      etc...
  
  On my Child entry pages I want to pull out the other child entries under that parent to use as navigation. I think this should be fairly straight forward but I can not find any documentation on it. So far I have the below but this pulls out all level 2 child entries and not just the entries for the specified parent.
  
  Any help much appreciated.
  
  ```
  {% for subnav in craft.entries.section('mySection').level(2).find() %}
      <li><a href="{{ subnav.url }}">{{ subnav.title }}</a></li>
  {% endfor %}
  
  ```
  
  **Tags:** structure, navigation
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2015-07-30. Score: 5 | Accepted answer
  
  Ok I've worked this out from above and adding some other code and now it works as below:
  
  ```
  {% set parent = entry.getAncestors().first() %}
  {% for subnav in craft.entries.section('mySection').descendantOf(parent).descendantDist('1') %}
      <li><a href="{{ subnav.url }}">{{ subnav.title }}</a></li>
  {% endfor %}
  
  ```
  
  Hope this assists someone else.
  
  
  ---
  
  ### Answer by username_1 on 2018-09-03. Score: 2
  
  Sometimes you need the same parent/siblings menu from various POVs (parent or children). Here's what I came up with:
  
  ```
  {# Parent / Children subnavigation, either from the perspective of the parent or a child #}
  
  {% if entry.level == 1 %}
    {% set parent = entry %}
    {% set children = entry.getDescendants().all() %}
  {% elseif entry.level == 2 %}
    {% set parent = entry.getAncestors().one() %}
    {% set children = entry.getSiblings().all() %}
  {% endif %}
  
  <h1><a href="{{parent.url}}">{{parent.title}}</a></h1>
  <ul>
      {% for child in children %}
      <li><a href="{{child.url}}">{{child.title}}</a></li>
      {% endfor %}
  </ul>
  
  ```
  
  I wonder if that's a detour and there's an easier way?
  
  
  ---
  
  ### Answer by username_2 on 2015-07-30. Score: 1
  
  For this you should be able to use the getSibling() method which:
  
  "Returns an ElementCriteriaModel object prepped to return the entry’s siblings (if it lives in a Structure section)."
  
  <https://docs.craftcms.com/v2/templating/entrymodel.html#getsiblings>
  
  ```
  {% set siblings = entry.getSiblings().all() %}
  
  <ul>
      {% for page in siblings %}
          <li class="item-contentmenu">
              <a href="{{ page.url }}">{{ page.title }}</a>
          </li>
      {% endfor %}
  </ul>
  
  ```
  
  > **Comments:**
  > **username_0**: I've tried this instead of the code below but with no success again the model returns Null for siblings. Any ideas why?  
  > **username_2**: could you show how you tried to implement the getSibling()? But to note it wont really improve on the answer you've given.  
  
  ---
  
  