How to get the order number of the current entry in a structure 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() }}.
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.