Answers.Body: <p>What about doing it like so:</p>
  
  <pre><code>{% set parent = entry.getParent() %}
  {% set siblingsPlusMe = parent.getDescendants(1) %}
  
  {% for entry in siblingsPlusMe %}
      &lt;li&gt;{{ entry.link }}&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-05T19:57:21.670Z
Answers.Text: Tested your code an it solves my problem. Thanks! In the meantime I also came up with a solution, see post below.
Answers.UserDisplayName: Alf Vestre
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-05T21:37:22.803Z
Answers.Text: And I was so fast in answering this, @AlfVestre! Not sure if it is a good idea to use `getChildren`, I read somewhere in the Craft source codes that it was deprecated (works for now, I know!), so better use `getParent().getDescendants(1)`, like in this example.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-05T22:18:34.407Z
Answers.Text: Checked the the Craft source code (BaseElementModel.php) and you're absolutely right that getChildren is deprecated and should not be used. I have updated my code below based on this.
Answers.UserDisplayName: Alf Vestre
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-04T22:40:54.057Z
Answers.LastActivityDate: 2014-12-04T22:40:54.057Z
Answers.UserDisplayName: carlcs
Answers.Body: <p>There are two possibilities. If the entry has a parent, then the entry+siblings will be all the children of that parent. If the entry does not have a parent (because it is a top level entry), then entry+siblings will be all the top level entries of the section.</p>
  
  <pre><code>{# define siblingsPlusMe so it is in scope outside of the if #}
  {% set siblingsPlusMe = [] %}
  
  {% if entry.level == 1 %} {# no parent #}
    {% set siblingsPlusMe = craft.entries.section(entry.section).level(1) %}
  
  {% else %} {# parent #}
    {% set siblingsPlusMe = entry.parent.children %}
  
  {% endif %}
  
  {# now that it is set, we can use it #}
  {% for sibling in siblingsPlusMe %}
    ...
  {% end for %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-11T19:28:21.333Z
Answers.LastActivityDate: 2015-09-11T19:28:21.333Z
Answers.UserDisplayName: Marion Newlevant
Answers.Body: <p>I ran into a problem trying to use the above solution, as <code>getParent()</code> wasn't returning anything (i think this may be because the entry url's i was trying to output where not children of another entry within the section?). Instead i did the following:</p>
  
  <pre><code>&lt;ul&gt;
    {% set sectionHandle = entry.getSection().handle %}
    {% set pages = craft.entries.section(sectionHandle).level(1) %}
      {% for page in pages %}
        &lt;li&gt;{{ page.getLink() }}&lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>I was following this tutorial: <a href="http://buildwithcraft.com/help/structure-nav" rel="nofollow">http://buildwithcraft.com/help/structure-nav</a> but it was requiring me to specify a handle name for which section to use. I was trying to create a generic template for multiple sections, so wanted to get the section of the current entry dynamically. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-10T10:44:17.223Z
Answers.LastActivityDate: 2015-09-10T10:44:17.223Z
Answers.UserDisplayName: alexr
Answers.Body: <p>This will also work:</p>
  
  <pre><code>{% for sibling in entry.parent().children() %}
      &lt;li&gt;{{ sibling.link }}&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
  <p>The code above uses deprecated Craft properties, use this instead:</p>
  
  <pre><code>{% for sibling in entry.getParent().getDescendants(1) %}
      &lt;li&gt;{{ sibling.link }}&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-05T20:00:11.383Z
Answers.LastActivityDate: 2014-12-05T22:22:06.740Z
Answers.LastEditDate: 2014-12-05T22:22:06.740Z
Answers.UserDisplayName: Alf Vestre
Body: <p>I'm trying to output all the siblings of the current entry in a multi level structure like this:</p>
  
  <pre><code>{% for sibling in entry.siblings() %}
      &lt;li&gt;{{ sibling.link }}&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
  <p>This works well, but how can I make this output all the siblings and the current entry?</p>
  
  <p>I know I could add:</p>
  
  <pre><code>    &lt;li&gt;{{ entry.link }}&lt;/li&gt;
  </code></pre>
  
  <p>before or after the sibling.link, but that would mess up the sort order.</p>
  
  <p>If this can't be done this way, maybe I could somehow output the current branch/depth using a different approach? Any suggestions?</p>
  
Tags: <entries><structure>
Title: How to output siblings including the current entry?
ThreadText: # How to output siblings including the current entry?
  
  (Asked by: username_0 on 2014-12-04)
  
  I'm trying to output all the siblings of the current entry in a multi level structure like this:
  
  ```
  {% for sibling in entry.siblings() %}
      <li>{{ sibling.link }}</li>
  {% endfor %}
  
  ```
  
  This works well, but how can I make this output all the siblings and the current entry?
  
  I know I could add:
  
  ```
      <li>{{ entry.link }}</li>
  
  ```
  
  before or after the sibling.link, but that would mess up the sort order.
  
  If this can't be done this way, maybe I could somehow output the current branch/depth using a different approach? Any suggestions?
  
  **Tags:** entries, structure
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_1 on 2014-12-04. Score: 5 | Accepted answer
  
  What about doing it like so:
  
  ```
  {% set parent = entry.getParent() %}
  {% set siblingsPlusMe = parent.getDescendants(1) %}
  
  {% for entry in siblingsPlusMe %}
      <li>{{ entry.link }}</li>
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Tested your code an it solves my problem. Thanks! In the meantime I also came up with a solution, see post below.  
  > **username_1**: And I was so fast in answering this, @username_0! Not sure if it is a good idea to use `getChildren`, I read somewhere in the Craft source codes that it was deprecated (works for now, I know!), so better use `getParent().getDescendants(1)`, like in this example.  
  > **username_0**: Checked the the Craft source code (BaseElementModel.php) and you're absolutely right that getChildren is deprecated and should not be used. I have updated my code below based on this.  
  
  ---
  
  ### Answer by username_2 on 2015-09-11. Score: 2
  
  There are two possibilities. If the entry has a parent, then the entry+siblings will be all the children of that parent. If the entry does not have a parent (because it is a top level entry), then entry+siblings will be all the top level entries of the section.
  
  ```
  {# define siblingsPlusMe so it is in scope outside of the if #}
  {% set siblingsPlusMe = [] %}
  
  {% if entry.level == 1 %} {# no parent #}
    {% set siblingsPlusMe = craft.entries.section(entry.section).level(1) %}
  
  {% else %} {# parent #}
    {% set siblingsPlusMe = entry.parent.children %}
  
  {% endif %}
  
  {# now that it is set, we can use it #}
  {% for sibling in siblingsPlusMe %}
    ...
  {% end for %}
  
  ```
  
  
  ---
  
  ### Answer by username_3 on 2015-09-10. Score: 1
  
  I ran into a problem trying to use the above solution, as `getParent()` wasn't returning anything (i think this may be because the entry url's i was trying to output where not children of another entry within the section?). Instead i did the following:
  
  ```
  <ul>
    {% set sectionHandle = entry.getSection().handle %}
    {% set pages = craft.entries.section(sectionHandle).level(1) %}
      {% for page in pages %}
        <li>{{ page.getLink() }}</li>
      {% endfor %}
  </ul>
  
  ```
  
  I was following this tutorial: <http://buildwithcraft.com/help/structure-nav> but it was requiring me to specify a handle name for which section to use. I was trying to create a generic template for multiple sections, so wanted to get the section of the current entry dynamically.
  
  
  ---
  
  ### Answer by username_0 on 2014-12-05. Score: 1
  
  This will also work:
  
  ```
  {% for sibling in entry.parent().children() %}
      <li>{{ sibling.link }}</li>
  {% endfor %}
  
  ```
  
  The code above uses deprecated Craft properties, use this instead:
  
  ```
  {% for sibling in entry.getParent().getDescendants(1) %}
      <li>{{ sibling.link }}</li>
  {% endfor %}
  
  ```
  
  
  ---
  
  