1

I have a problem finding a simple and easy solution to sort child-elements in it's parent. I don't want to have them sorted by the sorting-property of the child but some other value (in this example sort_value).

The parent has the property child_elements, and the child has a property sort_value.

I've already tried adding the following statement to the defaultOrderings of the ParentRepository:

'child_elements.sort_value' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING

I've also tried with childElements.sort_value and childElements.sortValue but that didn't work in either way.

I've found some solutions like sorting the children in the template using vhs-viewhelper or with injecting the childRepository into the ParentModel which then calls the findAll-function on the child in the getter-function of the parent (which is really dirty)...

Is there a mistake I'm not aware of in the defaultOrderings-statement? Or is there simply not such a simple way to do it?

The childRepository already has it's defaultOrderings set to the sortValue. The functions used for getting the parent is findAll or findByUid so no custom repository function.

What I want is to get the parent-object with it's sorted children by the children's field sort_value.

Thanks for your help.

Kathara
  • 1,226
  • 1
  • 12
  • 36
  • Maybe one of this helps: https://blog.teamgeist-medien.de/2014/12/extbase-sortierung-von-child-objects-objectstorages-irre.html https://stackoverflow.com/questions/25807394/typo3-extbase-how-to-sort-child-objects – exotec Dec 05 '19 at 20:29
  • @exotec I've already found and tried the solution in the blog-post but it didn't work. Nothing changed at all. For the time being I've used the v:sort with an iteration in fluid but it's not my preferred solution. I'm surprised that there doesn't seem to exist such a "simple" functionality (which could be solved with the solution above with defaultSorting)... – Kathara Dec 10 '19 at 15:45

0 Answers0