Answers.Body: <p><a href="http://buildwithcraft.com/docs/templating/entrymodel#getPrev" rel="nofollow">getPrev</a>, <a href="http://buildwithcraft.com/docs/templating/entrymodel#getNext" rel="nofollow">getNext</a>, <a href="http://buildwithcraft.com/docs/templating/entrymodel#getPrevSibling" rel="nofollow">getPrevSibling</a>, <a href="http://buildwithcraft.com/docs/templating/entrymodel#getNextSibling" rel="nofollow">getNextSibling</a> all specify an entry relative to the current one. <code>prevChild</code> and <code>nextChild</code> if they existed would somehow specify an entry relative to a child of the current entry. They don't exist.</p>
  
  <p>What you can do is paginate through the children. Here I use <code>.limit(1)</code> to page through them one at a time, but you could fetch more.</p>
  
  <pre><code>{% set prePaginatedEntries = entry.getChildren().limit(1) %}
  {% paginate prePaginatedEntries as entries %}
    {% for oneChild in entries %}
      {# do whatever with oneChild #}
    {% endfor %}
    {# pagination links #}
    {% if paginate.prevUrl %}
      &lt;a href="{{ paginate.prevUrl }}"&gt;Previous Page&lt;/a&gt;
    {% endif %}
  
    {% if paginate.nextUrl %}
      &lt;a href="{{ paginate.nextUrl }}"&gt;Next Page&lt;/a&gt;
    {% endif %}
  {% endpaginate %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T12:59:21.110Z
Answers.LastActivityDate: 2014-07-17T12:59:21.110Z
Answers.UserDisplayName: Marion Newlevant
Answers.Body: <p>There is no <code>getPrevChild</code> and <code>getNextChild</code> methods, but the <code>getPrevSibling</code> and <code>getNextSibling</code> should still serve your purpose. You would simply call it on the child entry instead of its parent.</p>
  
  <p>Another method would be to gather all the children in one go and paginate them via JavaScript.</p>
  
  <p>And yet another method would be the <a href="http://buildwithcraft.com/docs/templating/tags#paginate" rel="nofollow"><code>paginate</code></a> tag. <code>paginate</code> works using any criteria. When you use <code>getChildren</code>, you are getting criteria that's used to pull the child entries.</p>
  
  <pre><code>{% paginate entry.getChildren().limit(1) as entries %}
  </code></pre>
  
  <p>As per the docs, you would then get the <code>paginate.prevUrl</code> and <code>paginate.nextUrl</code> variables to page through as needed.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T13:42:18.927Z
Answers.Text: Hi Bryan, ref. your first option how would I get the child entry instead of its parent?
Answers.UserDisplayName: Gareth
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T13:48:21.640Z
Answers.Text: `entry.getChildren().first()`
  
  All references to entries, assets, categories, etc. is just that: references. They don't contain the actual elements, but an ElementCriteriaModel that can pull those elements. In this case, the children of your parent entry.
Answers.UserDisplayName: Bryan Redeagle
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T13:57:41.133Z
Answers.Text: Bryan, please see my code update - it doesn't work, sorry I have probably misunderstood.
Answers.UserDisplayName: Gareth
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T14:01:42.643Z
Answers.Text: It's `getNextSibling` and `getPrevSibling`. You forgot the `get` in the method name. Also, you should think about how your urls will look. This might send you to the sibling's full page which will need to handle the parent differently that how you seem to have in this example.
Answers.UserDisplayName: Bryan Redeagle
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T14:08:24.297Z
Answers.Text: `entry.getChildren().first().prevSibling()` is never going to find anything - you are asking for the one before the first one.
Answers.UserDisplayName: Marion Newlevant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T14:22:15.697Z
Answers.Text: This is true. Based on your example above I would suggest using `paginate` instead. It would keep the parent entry on each page that way. You may have to set up a route for it to work, but I'm not positive on that.
Answers.UserDisplayName: Bryan Redeagle
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T14:48:51.663Z
Answers.Text: Thank you will look at Marion's `paginate` option next.
Answers.UserDisplayName: Gareth
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-17T13:03:48.717Z
Answers.LastActivityDate: 2014-07-17T13:03:48.717Z
Answers.UserDisplayName: Bryan Redeagle
Body: <p>I am trying to figure out how to page through only the children of the top level section entry being displayed, I have looked at <a href="https://craftcms.stackexchange.com/questions/333/how-do-you-page-through-entries-in-a-structure/334#334">this question</a> but as I say I am after only the children not the siblings.</p>
  
  <p>Is there a <code>prevChild()</code> and <code>nextChild()</code> or something similar I can't see them in the <a href="http://buildwithcraft.com/docs/templating/entrymodel#methods" rel="nofollow noreferrer">docs</a>.</p>
  
  <p><strong>Response to Bryan</strong></p>
  
  <p>So I would do something like:</p>
  
  <pre class="lang-twig prettyprint-override"><code>{% set prevDatabyteSeries = entry.getChildren().first().getPrevSibling() %}
  {% set nextDatabyteSeries = entry.getChildren().first().getNextSibling() %}
  
  {% if prevDatabyteSeries %}
  &lt;a href="{{ prevDatabyteSeries.url }}" class="icon-alone paginate-arrow"&gt;
    &lt;i class="icon-arrow-left"&gt;&lt;/i&gt;
  &lt;/a&gt;
  {% endif %}
  
  {% if nextDatabyteSeries %}
  &lt;a href="{{ nextDatabyteSeries.url }}" class="icon-alone paginate-arrow"&gt;
    &lt;i class="icon-arrow-right"&gt;&lt;/i&gt;
  &lt;/a&gt;
  {% endif %}
  </code></pre>
  
Tags: <sections><previous-next>
Title: How do you page through child entries in a structure?
ThreadText: # How do you page through child entries in a structure?
  
  (Asked by: username_0 on 2014-07-17)
  
  I am trying to figure out how to page through only the children of the top level section entry being displayed, I have looked at [this question](https://craftcms.stackexchange.com/questions/333/how-do-you-page-through-entries-in-a-structure/334#334) but as I say I am after only the children not the siblings.
  
  Is there a `prevChild()` and `nextChild()` or something similar I can't see them in the [docs](http://buildwithcraft.com/docs/templating/entrymodel#methods).
  
  **Response to username_2**
  
  So I would do something like:
  
  ```twig
  {% set prevDatabyteSeries = entry.getChildren().first().getPrevSibling() %}
  {% set nextDatabyteSeries = entry.getChildren().first().getNextSibling() %}
  
  {% if prevDatabyteSeries %}
  <a href="{{ prevDatabyteSeries.url }}" class="icon-alone paginate-arrow">
    <i class="icon-arrow-left"></i>
  </a>
  {% endif %}
  
  {% if nextDatabyteSeries %}
  <a href="{{ nextDatabyteSeries.url }}" class="icon-alone paginate-arrow">
    <i class="icon-arrow-right"></i>
  </a>
  {% endif %}
  
  ```
  
  **Tags:** sections, previous-next
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-07-17. Score: 3 | Accepted answer
  
  [getPrev](http://buildwithcraft.com/docs/templating/entrymodel#getPrev), [getNext](http://buildwithcraft.com/docs/templating/entrymodel#getNext), [getPrevSibling](http://buildwithcraft.com/docs/templating/entrymodel#getPrevSibling), [getNextSibling](http://buildwithcraft.com/docs/templating/entrymodel#getNextSibling) all specify an entry relative to the current one. `prevChild` and `nextChild` if they existed would somehow specify an entry relative to a child of the current entry. They don't exist.
  
  What you can do is paginate through the children. Here I use `.limit(1)` to page through them one at a time, but you could fetch more.
  
  ```
  {% set prePaginatedEntries = entry.getChildren().limit(1) %}
  {% paginate prePaginatedEntries as entries %}
    {% for oneChild in entries %}
      {# do whatever with oneChild #}
    {% endfor %}
    {# pagination links #}
    {% if paginate.prevUrl %}
      <a href="{{ paginate.prevUrl }}">Previous Page</a>
    {% endif %}
  
    {% if paginate.nextUrl %}
      <a href="{{ paginate.nextUrl }}">Next Page</a>
    {% endif %}
  {% endpaginate %}
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2014-07-17. Score: 1
  
  There is no `getPrevChild` and `getNextChild` methods, but the `getPrevSibling` and `getNextSibling` should still serve your purpose. You would simply call it on the child entry instead of its parent.
  
  Another method would be to gather all the children in one go and paginate them via JavaScript.
  
  And yet another method would be the [`paginate`](http://buildwithcraft.com/docs/templating/tags#paginate) tag. `paginate` works using any criteria. When you use `getChildren`, you are getting criteria that's used to pull the child entries.
  
  ```
  {% paginate entry.getChildren().limit(1) as entries %}
  
  ```
  
  As per the docs, you would then get the `paginate.prevUrl` and `paginate.nextUrl` variables to page through as needed.
  
  > **Comments:**
  > **username_0**: Hi username_2, ref. your first option how would I get the child entry instead of its parent?  
  > **username_2**: `entry.getChildren().first()`  All references to entries, assets, categories, etc. is just that: references. They don't contain the actual elements, but an ElementCriteriaModel that can pull those elements. In this case, the children of your parent entry.  
  > **username_0**: username_2, please see my code update - it doesn't work, sorry I have probably misunderstood.  
  > **username_2**: It's `getNextSibling` and `getPrevSibling`. You forgot the `get` in the method name. Also, you should think about how your urls will look. This might send you to the sibling's full page which will need to handle the parent differently that how you seem to have in this example.  
  > **username_1**: `entry.getChildren().first().prevSibling()` is never going to find anything - you are asking for the one before the first one.  
  > **username_2**: This is true. Based on your example above I would suggest using `paginate` instead. It would keep the parent entry on each page that way. You may have to set up a route for it to work, but I'm not positive on that.  
  > **username_0**: Thank you will look at username_1's `paginate` option next.  
  
  ---
  
  