I have an Extbase Model Article and a 1:n Relation Product. In Article TCA i have an inline field configuered. In my Article Template I want to display all related Products. These are oredered by uid. How can i change the ordering of the child objects to the field sorting to be able to manually sort them. ( In the backend form the sorting is possible, only diplaying them sorted by field sorting is not possible )
thanks, Lukas
I dont't really like the idea of doing basic sorting inside the view (mvc).
The Downside of most Database abstraction Layers ist, that you are quite often restricted to either mixup mvc or have a (sometimes slightly) lower performance.
I am at the same point right now. I am thinking about retrieving the parents (with their children attached). Then go into every single parent and get children for this parent in a sorted way.
The function
findSortedByName
inside the children repos is usingto retrieve only children of this parent and
to be able to give them back in an ordered way.
Warning: Depending on the size and quantity of all retrieved objects, this way might arise a huge performance issue.
Using the dot notation you can sort by properties of subobjects:
edit: Caught me off guard, I think I read your question wrong. Yes, this sorts by child objet, but it applies that to the parent object, of course. If you want to sort the child objects themselves, you have to set that sorting in the repository of the child object, as @Urs explained.
Here's how I do it, in the repository class:
The easiest way to sort child elements in a object storage is to manipulate the TCA.
Example:
With the filed 'foreign_sortby' => 'sorting', you can easily say on which field the childs should be ordered.