Answers.Body: <p>You can use the <a href="https://craftcms.com/docs/templating/entrymodel#hasDescendants" rel="nofollow"><code>hasDescendants()</code></a> method to filter out any parent entry with children. You have to use an ElementCriteriaModel with <code>.getPrev()</code> and <code>.getNext()</code>.</p>
  
  <pre><code>{% set entries = craft.entries.section( 'pages' ) %}
  {% set entryIds = [] %}
  
  {% for entry in entries %}
    {% if not entry.hasDescendants() %}
      {% set entryIds = entryIds|merge( [entry.id] ) %}
    {% endif %}
  {% endfor %}
  
  {% set criteria = craft.entries.id( entryIds ) %}
  
  {% set prevEntry = entry.getPrev( criteria ) %}
  {% set nextEntry = entry.getNext( criteria ) %}
  </code></pre>
  
  <p>You will also need to add logic to get the first and last entry is next or previous is null.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-19T15:25:24.597Z
Answers.Text: Hmm, that seems to make no difference at all. It still gives me the next entry as being a parent entry.
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-19T15:43:41.077Z
Answers.Text: Updated answer.
Answers.UserDisplayName: Luke Pearce
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-19T15:51:30.450Z
Answers.Text: Hmm, nope, now the prev next links don't show at all. No error though!
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-19T15:52:24.437Z
Answers.Text: Ah no, you had changed the section name to test and i didn't pick that up! Works a treat, thank you!!!!
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-19T14:41:54.227Z
Answers.LastActivityDate: 2016-07-19T15:55:40.420Z
Answers.LastEditDate: 2016-07-19T15:55:40.420Z
Answers.UserDisplayName: Luke Pearce
Body: <p>I have a Structure with my entries in. How can I hide the parent entries that contain children? I still want to show the parents children.</p>
  
  <p>For example I want all the below entries bar "About" and "Services"</p>
  
  <pre><code>- Home
  - About
      - Sub
      - Sub
      - Sub
  - Stuff
  - Services
      - Sub
      - Sub
      - Sub
  - Things 
  </code></pre>
  
  <p>So, this is my code right now</p>
  
  <pre><code>{# Set parameters for prev/next elements list #}
  {% set params = craft.entries.section('pages') %}
  
  {# Get the prev/next elements #}
  {% set prevEntry = entry.getPrev(params) %}
  {% set nextEntry = entry.getNext(params) %}
  </code></pre>
  
  <p>Do I need to modify the params to remove the entries that are parents?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-07-19T14:26:12.083Z
Comments.Text: Is this only being used to navigate between the previous and next entry?
Comments.UserDisplayName: Luke Pearce
Tags: <structure><pagination>
Title: Only fetch structure entries that are first level or sub level that don't have a parent
ThreadText: # Only fetch structure entries that are first level or sub level that don't have a parent
  
  (Asked by: username_0 on 2016-07-19)
  
  I have a Structure with my entries in. How can I hide the parent entries that contain children? I still want to show the parents children.
  
  For example I want all the below entries bar "About" and "Services"
  
  ```
  - Home
  - About
      - Sub
      - Sub
      - Sub
  - Stuff
  - Services
      - Sub
      - Sub
      - Sub
  - Things 
  
  ```
  
  So, this is my code right now
  
  ```
  {# Set parameters for prev/next elements list #}
  {% set params = craft.entries.section('pages') %}
  
  {# Get the prev/next elements #}
  {% set prevEntry = entry.getPrev(params) %}
  {% set nextEntry = entry.getNext(params) %}
  
  ```
  
  Do I need to modify the params to remove the entries that are parents?
  
  **Tags:** structure, pagination
  
  > **Comments:**
  > **username_1**: Is this only being used to navigate between the previous and next entry?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-07-19. Score: 3 | Accepted answer
  
  You can use the [`hasDescendants()`](https://craftcms.com/docs/templating/entrymodel#hasDescendants) method to filter out any parent entry with children. You have to use an ElementCriteriaModel with `.getPrev()` and `.getNext()`.
  
  ```
  {% set entries = craft.entries.section( 'pages' ) %}
  {% set entryIds = [] %}
  
  {% for entry in entries %}
    {% if not entry.hasDescendants() %}
      {% set entryIds = entryIds|merge( [entry.id] ) %}
    {% endif %}
  {% endfor %}
  
  {% set criteria = craft.entries.id( entryIds ) %}
  
  {% set prevEntry = entry.getPrev( criteria ) %}
  {% set nextEntry = entry.getNext( criteria ) %}
  
  ```
  
  You will also need to add logic to get the first and last entry is next or previous is null.
  
  > **Comments:**
  > **username_0**: Hmm, that seems to make no difference at all. It still gives me the next entry as being a parent entry.  
  > **username_1**: Updated answer.  
  > **username_0**: Hmm, nope, now the prev next links don't show at all. No error though!  
  > **username_0**: Ah no, you had changed the section name to test and i didn't pick that up! Works a treat, thank you!!!!  
  
  ---
  
  