Answers.Body: <p>You can use the <code>ancestors</code> property (which is a shortcut to <a href="http://buildwithcraft.com/docs/templating/entrymodel#getAncestors" rel="nofollow">getAncestors()</a>).</p>
  
  <pre><code>{% set targetEntry = entry %}
  {% if entry.level &gt; 1 %}
       {% set targetEntry = entry.ancestors.last %}
  {% endif %}
  </code></pre>
  
  <p>To retrieve an ancestor with a specific level:</p>
  
  <pre><code>{% set targetEntry = entry %}
  {% for ancestorEntry in entry.ancestors %}
      {% if ancestorEntry.level == "2" %}
          {% set targetEntry = ancestorEntry %}
      {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>And if you want a specific distance (i.e. 2 levels above), you can use the distance property.</p>
  
  <pre><code>{% set targetEntry = entry %}
  {% if entry.level &gt; 1 %}
      {% set targetEntry = entry.ancestors(2).last %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-01T08:08:55.590Z
Answers.Text: Thanks, works great on any of the sub-pages of the main ancestor/parent page, however when I visit the parent aka level 1 page nothing shows up :(
Answers.UserDisplayName: Mark H.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-01T08:34:17.093Z
Answers.Text: Yes — If it's a level 1 entry then it has no ancestors. You would want to check the `level` or `entry.parent` or `entry.ancestors|length` first. Updated answer with example.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-01T01:40:45.843Z
Answers.LastActivityDate: 2015-02-01T08:33:27.210Z
Answers.LastEditDate: 2015-02-01T08:33:27.210Z
Answers.UserDisplayName: Douglas McDonald
Answers.Body: <p>So, here is my final solution it looks ugly but works. I'm pretty sure that it could be done in a more effective / nicely looking way but this is my first website on Craft :)</p>
  
  <pre><code>                        {% set topic = entry.ancestors.first %}
                          {% if topic %}
                              &lt;a href="{{ topic.url }}"&gt;{{ topic.title }}&lt;/a&gt;
                          {% else %}
                              {{ entry.title }}
                          {% endif %}
                          &lt;/h4&gt;
                          &lt;ul class="clearfix"&gt;
                          {% if entry.level &gt; 1 %}
                          {% for subsection in craft.entries.descendantOf(topic) if subsection.type != "state" %}
                              &lt;li class="icon-list"&gt;
                                  &lt;a href="{{ subsection.url }}"&gt;{{ subsection.title }}&lt;/a&gt;
                              {% if craft.request.segment(1) == subsection.slug %}
                                  &lt;span class="thumb-icon-list"&gt;&lt;i class="fa fa-caret-right"&gt;&lt;/i&gt;&lt;/span&gt;
                              {% endif %}
                              &lt;/li&gt;
                          {% endfor %}
  
                          {% else %}
  
                          {% for subsection in craft.entries.descendantOf(entry.id) if subsection.type != "state" %}
                              &lt;li class="icon-list"&gt;
                                  &lt;a href="{{ subsection.url }}"&gt;{{ subsection.title }}&lt;/a&gt;
                              {% if craft.request.segment(1) == subsection.slug %}
                                  &lt;span class="thumb-icon-list"&gt;&lt;i class="fa fa-caret-right"&gt;&lt;/i&gt;&lt;/span&gt;
                              {% endif %}
                              &lt;/li&gt;
                          {% endfor %}
                          {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-01T18:07:22.823Z
Answers.LastActivityDate: 2015-02-01T18:07:22.823Z
Answers.UserDisplayName: Mark H.
Body: <p>What I'm trying to do is to display child pages of a parent page. So far so good.</p>
  
  <pre><code>                {% if entry.parent %}
                      &lt;div class="widget clearfix"&gt;
                          &lt;h4 class="widgettitle"&gt;&lt;a href="{{ entry.parent.url }}"&gt;{{ entry.parent.title }}&lt;/a&gt;&lt;/h4&gt;
                          &lt;ul class="clearfix"&gt;
                          {% set topic = entry.parent.id %}
                          {% for subsection in craft.entries.descendantOf(topic) if subsection.type != "state" %}
                              &lt;li class="cat-item"&gt;&lt;a href="{{ subsection.url }}"&gt;{{ subsection.title }}&lt;/a&gt;&lt;/li&gt;
                          {% endfor %}
                          &lt;/ul&gt;
                      &lt;/div&gt;
                  {% endif %}
  </code></pre>
  
  <p>However if the sub page has another child page everything goes wrong as I see the results of the parent page that is a child itself.</p>
  
  <p>How do  I ignore the hierarchy and display the results of level 1 aka grand parent page / topic?</p>
  
  <p>Thanks.</p>
  
Tags: <navigation>
Title: Easy Nav Question
ThreadText: # Easy Nav Question
  
  (Asked by: username_0 on 2015-02-01)
  
  What I'm trying to do is to display child pages of a parent page. So far so good.
  
  ```
                  {% if entry.parent %}
                      <div class="widget clearfix">
                          <h4 class="widgettitle"><a href="{{ entry.parent.url }}">{{ entry.parent.title }}</a></h4>
                          <ul class="clearfix">
                          {% set topic = entry.parent.id %}
                          {% for subsection in craft.entries.descendantOf(topic) if subsection.type != "state" %}
                              <li class="cat-item"><a href="{{ subsection.url }}">{{ subsection.title }}</a></li>
                          {% endfor %}
                          </ul>
                      </div>
                  {% endif %}
  
  ```
  
  However if the sub page has another child page everything goes wrong as I see the results of the parent page that is a child itself.
  
  How do I ignore the hierarchy and display the results of level 1 aka grand parent page / topic?
  
  Thanks.
  
  **Tags:** navigation
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-02-01. Score: 3
  
  You can use the `ancestors` property (which is a shortcut to [getAncestors()](http://buildwithcraft.com/docs/templating/entrymodel#getAncestors)).
  
  ```
  {% set targetEntry = entry %}
  {% if entry.level > 1 %}
       {% set targetEntry = entry.ancestors.last %}
  {% endif %}
  
  ```
  
  To retrieve an ancestor with a specific level:
  
  ```
  {% set targetEntry = entry %}
  {% for ancestorEntry in entry.ancestors %}
      {% if ancestorEntry.level == "2" %}
          {% set targetEntry = ancestorEntry %}
      {% endif %}
  {% endfor %}
  
  ```
  
  And if you want a specific distance (i.e. 2 levels above), you can use the distance property.
  
  ```
  {% set targetEntry = entry %}
  {% if entry.level > 1 %}
      {% set targetEntry = entry.ancestors(2).last %}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks, works great on any of the sub-pages of the main ancestor/parent page, however when I visit the parent aka level 1 page nothing shows up :(  
  > **username_1**: Yes — If it's a level 1 entry then it has no ancestors. You would want to check the `level` or `entry.parent` or `entry.ancestors|length` first. Updated answer with example.  
  
  ---
  
  ### Answer by username_0 on 2015-02-01. Score: 0
  
  So, here is my final solution it looks ugly but works. I'm pretty sure that it could be done in a more effective / nicely looking way but this is my first website on Craft :)
  
  ```
                          {% set topic = entry.ancestors.first %}
                          {% if topic %}
                              <a href="{{ topic.url }}">{{ topic.title }}</a>
                          {% else %}
                              {{ entry.title }}
                          {% endif %}
                          </h4>
                          <ul class="clearfix">
                          {% if entry.level > 1 %}
                          {% for subsection in craft.entries.descendantOf(topic) if subsection.type != "state" %}
                              <li class="icon-list">
                                  <a href="{{ subsection.url }}">{{ subsection.title }}</a>
                              {% if craft.request.segment(1) == subsection.slug %}
                                  <span class="thumb-icon-list"><i class="fa fa-caret-right"></i></span>
                              {% endif %}
                              </li>
                          {% endfor %}
  
                          {% else %}
  
                          {% for subsection in craft.entries.descendantOf(entry.id) if subsection.type != "state" %}
                              <li class="icon-list">
                                  <a href="{{ subsection.url }}">{{ subsection.title }}</a>
                              {% if craft.request.segment(1) == subsection.slug %}
                                  <span class="thumb-icon-list"><i class="fa fa-caret-right"></i></span>
                              {% endif %}
                              </li>
                          {% endfor %}
                          {% endif %}
  
  ```
  
  
  ---
  
  