For coders TYPO3 Tech Corner

Extbase: Sorting for IRRE Child Elements

Extbase: Sorting for IRRE Child Elements

'faqs' => [ 'config' => [ 'type' => 'inline', 'foreign_table' => 'tx_myextension_domain_model_faq', 'foreign_field' => 'faq', 'appearance' => [ 'collapseAll' => 0, 'levelLinksPosition' => 'top', 'showSynchronizationLink' => 1, 'showPossibleLocalizationRecords' => 1, 'useSortable' => 1, 'showAllLocalizationLink' => 1 ], ],

In order for the records to be sorted in the backend, the field must be set to "useSortable = 1" in the field settings of this relation in the TCA. This means that I can already sort the data records in the backend. Of course, there must also be a "sorting" field in the table "tx_myextension_domain_model_faq". However, Extbase will not yet output these data records sorted, but always in the order in which they were entered. To get the sorting into the data model, the TCA property 'foreign_sortby' => 'sorting' must be set. 

The final result looks like this:

'faqs' => [ 'config' => [ 'type' => 'inline', 'foreign_table' => 'tx_myextension_domain_model_faq', 'foreign_field' => 'faq', 'foreign_sortby' => 'sorting', 'appearance' => [ 'collapseAll' => 0, 'levelLinksPosition' => 'top', 'showSynchronizationLink' => 1, 'showPossibleLocalizationRecords' => 1, 'useSortable' => 1, 'showAllLocalizationLink' => 1 ], ],

Now Extbase will also output our IRRE relation as the editor sets it in the backend.

Back

"Code faster, look at the time" - does this sound familiar to you?

How about time and respect for code quality? Working in a team? Automated tests?

Join us