[TYPO3-mvc] Set sorting of relations

Dennis Ahrens dennis.ahrens at googlemail.com
Wed Nov 17 10:46:55 CET 2010


Hi Pascal,

Pascal Jungblut wrote:
> Hey,
> 
> I ran into a problem with the sorting of objects that are mapped with a m:m-table and therefore stored in an ObjectStorage. Since r1257 Extbase respects the 'sorting' and 'sorting_foreign' fields from the TCA, but it seems to me that it's not possible to manipulate the sorting from within Extbase (without writing SQL). 
> 
> Is it already possible to sort related objects? If not, what would be a good way to implement it? Personally I'd implement something like $objectStorage->addBefore/After($newObject, $existingObject) or similar, but I have no idea how that would effect v5. What do you guys think?

I've solved sorting by rewriting the ObjectStorage in the way i'd like 
the related objects to be sorted. Iterating over the "old" ObjectStorage 
applying the objects in the order i'd like to achieve to the new 
ObjectStorage. After that i replace the assigned ObjectStorage with the 
"sorted" one.
I don't know if there is a cleaner way to do this - but it works for me.

regards
Dennis


More information about the TYPO3-project-typo3v4mvc mailing list