Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello, How do I automatically sort my collection by a date field ?
Thank you
Comments
Comment #1
jmuzz CreditAttribution: jmuzz commentedComment #2
bunthorne CreditAttribution: bunthorne commentedI would find this helpful as well. Currently my FC table sorts by the order the items were added (the FC ID). But my items are actually performance dates/times, so I would want to be able to add additional dates/times in the middle if needed.
The workaround is to create a View block of the Field Collection items with a Contextual Filter to the Content Pages that own them, then display them in a block below the Content page.
But if some table management options could be added, such as one finds built into to Views, it would make the FC table much more useful.
Changing to Feature Request.
Comment #3
giupenni CreditAttribution: giupenni commented+1
Comment #4
kiritoly CreditAttribution: kiritoly at Interdruper commentedSorting obviously may be performed at rendering time...
But if you need to set the order in the database (so the widgets will show the items already sorted), you can use this snippet for sorting the field collection items by any of its fields, before saving a node: