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.