1

This question is related to this thread.

{% for sibling in entry.getSiblings() %}  
{{ sibling.title }} {{ sibling.orderNumber }}
{% endfor %}

I thought you could pick this out of the ElementCriteriaModel, but that doesn't seem to be possible/available. Twig's for loop won't work either.

The result I am looking for is to echo the order number of the siblings in a structure.

Parent
Child order number 1
Child order number 2
Child order number 3

1 Answer 1

1

Building upon the answer I posted to this question How to get the order number of the current entry in a structure, you should be able to get the order number in your for-loop like so:

{% set parent = entry.getParent() %}
{% set childrenIds = parent.getChildren().ids() %}

{% for sibling in entry.getSiblings() %}
    {% set orderNumber = craft.entries({
        id: siblingsIds,
        order: 'lft desc',
        positionedBefore: sibling,
    }).total() + 1 %}

    {{ sibling.title }} ({{ orderNumber }})
{% endfor %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.