1

I want to order entries in an "Entries field" by the order I added them to the field. So Anastasia would be first and Beni would be last.

enter image description here

My only idea was .fixedOrder like you would do it with an asset field:

{% for entry in craft.entries.section('musiker').relatedTo(entry).fixedOrder(true) %}
   {{ entry.name }}
{% endfor %}

But that does nothing.

0

2 Answers 2

2

Looking at your screenshot it seems like you just want to list entries straight from the entries field. If that's the case, you won't need to use the relatedTo param. Give this code a try:

{% for entry in entry.fieldHandle %}
    <p>{{ entry.title }}</p>
{% endfor %}
2
  • :D Ooops. You are right. My code is unnecessarily complicated.
    – KSPR
    Commented Mar 9, 2015 at 13:57
  • 1
    @Kaspar The relatedTo param would have been ideal if, for example you wanted to find which entries have 'Anastasia' in the 'Musiker' entry field. But yes in this instance, a simple for loop is all that's needed :)
    – Jamie Wade
    Commented Mar 9, 2015 at 14:31
3

It's order('sortOrder') instead of fixedOrder(true).

{% set entries = craft.entries({
    relatedTo: { sourceElement: entry, field: 'entriesFieldHandle' },
    order: 'sortOrder',
    limit: null
}) %}

If you don't make any further modifications to the params (i.e. reverse order, other limit) there's also the short syntax for the above that Jamie already suggested:

{% set entries = entry. entriesFieldHandle %}
3
  • I tried that and it gave a error. I guess it was due to the related param. But no it's no longer needed.
    – KSPR
    Commented Mar 9, 2015 at 13:58
  • Ahh that's strange, because I shamelessly copied it from the docs.
    – carlcs
    Commented Mar 9, 2015 at 14:53
  • Yes. I did the same. Thats Why I asked in the first place. I thought sortOrder must be a placeholder then.
    – KSPR
    Commented Mar 9, 2015 at 15:02

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.