<p>There's a <code>positionedBefore</code> parameter for <code>craft.entries</code>. Use this with a criteria model filtered to
show the entries you are interested in only.</p>

<pre><code>{% set parent = entry.getParent() %}
{% set siblingsIds = parent.getChildren().ids() %}

{% set positionedBefore = craft.entries({
    id: siblingsIds,
    order: 'lft desc',
    positionedBefore: entry,
}).total() %}
</code></pre>

<p>With the first two lines I'm getting the IDs of all of the entry's siblings. I then prepare a <code>craft.entries</code> criteria model using the siblings' IDs with the <code>id</code> parameter to query just for those entries, order them by <code>lft</code> in descending order (that's the db column Craft stores position info) and further filter with <code>positionedBefore</code> to get just the entries before <code>entry</code>.</p>

<p>Calling the <code>total</code> method returns the number of entries found.</p>

CC BY-SA 3.0
2016-01-14T11:12:50.873Z
Very clever, I get it now. I didn't know about the `lft` column. Thank you again!
Gareth
CC BY-SA 3.0
2016-01-14T10:51:48.807Z
Thank you @carlcs that seems to work perfect, could you just expand on your answer a little to help me understand exactly what its doing?
Gareth
CC BY-SA 3.0
2016-01-14T10:47:26.980Z
2016-01-14T11:03:30.447Z
2016-01-14T11:03:30.447Z
carlcs
<p>Is there a way in Craft to get the order property of the current entry when it's in a structure? For example say you have the following structure:</p>

<ul>
<li>Parent Page

<ul>
<li>Child One</li>
<li>Child Two</li>
<li>Child Three</li>
</ul></li>
</ul>

<p>Is there a way to get what order property Child Two is in relation to its siblings so in this case it would be 1 (zero based)?</p>

<p>In my templates I am wanting to be able to grab the order property for the current entry by doing something like <code>{{ entry.getOrder() }}</code>. </p>

<entrymodel><order>
How to get the order number of the current entry in a structure
# How to get the order number of the current entry in a structure

(Asked by: username_0 on 2016-01-14)

Is there a way in Craft to get the order property of the current entry when it's in a structure? For example say you have the following structure:

* Parent Page
  + Child One
  + Child Two
  + Child Three

Is there a way to get what order property Child Two is in relation to its siblings so in this case it would be 1 (zero based)?

In my templates I am wanting to be able to grab the order property for the current entry by doing something like `{{ entry.getOrder() }}`.

**Tags:** entrymodel, order

---

## 1 answers

### Answer by username_1 on 2016-01-14. Score: 7 | Accepted answer

There's a positionedBefore parameter for craft.entries. Use this with a criteria model filtered to
show the entries you are interested in only.
{% set parent = entry.getParent() %}
{% set siblingsIds = parent.getChildren().ids() %}

{% set positionedBefore = craft.entries({
    id: siblingsIds,
    order: 'lft desc',
    positionedBefore: entry,
}).total() %}

With the first two lines I'm getting the IDs of all of the entry's siblings. I then prepare a craft.entries criteria model using the siblings' IDs with the id parameter to query just for those entries, order them by lft in descending order (that's the db column Craft stores position info) and further filter with positionedBefore to get just the entries before entry.
Calling the total method returns the number of entries found.

> **Comments:**
> **username_0**: Thank you @carlcs that seems to work perfect, could you just expand on your answer a little to help me understand exactly what its doing?  
> **username_0**: Very clever, I get it now. I didn't know about the `lft` column. Thank you again!  

---

