Project

General

Profile

Actions

Bug #21710

closed

List modul doesn't sort m:m relation properly

Added by 4eyes GmbH almost 15 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2009-11-27
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.3
PHP Version:
4.3
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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)

Actions #1

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)?

Actions #2

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.

Actions #3

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?

Actions

Also available in: Atom PDF