Bug #21710
closedList modul doesn't sort m:m relation properly
0%
Description
If you use the list module to sort records according to their mm-relation you won't get any useful results.
My idea for a solution is adding the following code to class.db_list_extra.inc, after Line 409 (4.2.9)
if (isset($TCA[$table]['columns'][$queryParts['ORDERBY']]['config']['MM'])) {
$mmTable = $TCA[$table]['columns'][$queryParts['ORDERBY']]['config']['MM'];
$foreignTable = $TCA[$table]['columns'][$queryParts['ORDERBY']]['config']['foreign_table'];
$foreignTableLabelField = $TCA[$foreignTable]['ctrl']['label'];
$queryParts['SELECT'] = $table.'.'.str_replace(',',','.$table.'.',$queryParts['SELECT']);
$queryParts['SELECT'] .= ', GROUP_CONCAT('.$foreignTable.'.'.$foreignTableLabelField.') as tmp';
$queryParts['FROM'] .= ' LEFT JOIN '.$mmTable.' ON (uid_local = '.$table.'.uid)
LEFT JOIN '.$foreignTable.' ON (uid_foreign = '.$foreignTable.'.uid)';
$queryParts['ORDERBY'] = 'tmp';
$queryParts['GROUPBY'] = $table.'.uid';
$queryParts['WHERE'] = $table.'.'.$queryParts['WHERE'];
}
Of course is only a draft, there are several aspects not covered:
- hidden records in foreign table
- only one sorting direction
- group fields
Problem still exists in 4.3RC2
(issue imported from #M12789)
Updated by Alexander Opitz over 11 years ago
- Status changed from New to Needs Feedback
- Target version deleted (
0) - TYPO3 Version set to 4.3
The issue is very old, does this issue exists in newer versions of TYPO3 CMS (4.5 or 6.1)?
Updated by Alexander Opitz about 11 years ago
- Status changed from Needs Feedback to Closed
- Is Regression set to No
No feedback for over 90 days.
Updated by Jan Kornblum almost 10 years ago
This still exists in 4.5. Also affects sorting by a n:1 relation tables "label" column. Can anybody reopen this?