[TYPO3-mvc] Sorting of child records from mm relation
Jan Kornblum
jan.kornblum at gmx.de
Sat Jul 27 11:25:32 CEST 2013
Hi,
>> i have a object company. There I have a mm relation to subcategory.
>>
>> I my Extbase extension I fetch a company and want to show all assigned
>> subcategories => sorted by subcategory name.
>>
>> Is there a way to sort these child objects alphabetical without a
>> repository
>> find method?
>>
>>
>>
>> What's the best way to do? Should it be done over the model maybe?
> Hello. try adding "foreign_sortby", to your TCA company.php
> Something like
"foreign_sortby" will sort the childs, but in BE it will corrupt the
records after saving, as "foreign_sortby" is internal used for storing
integer-sorting values.
As far as i know (just had the similar situation), it is not possible
in extbase to sort "childs" (object storage), when you want to access
them by aggregate root, e.g. $parent->getChilds(). Somthing like
"default_foreign_sortby" is not yet implemented in extbase, why ever...
There seem to be two methods to achieve sorting of childs: One is
converting the object storage to an array and "usorting" it, the other
is a view helper from FED:
http://fedext.net/viewhelpers/fed/Data/SortViewHelper.html
Last one helped in my case.
Regards, Jan
More information about the TYPO3-project-typo3v4mvc
mailing list