Bug #19483
closedalternativeSortingField does not work for other languages
0%
Description
If you build a TMENU with an alternativeSortingField-entry, in the default language, the sort-order is right. if you switch the language, the menu-entries are translated, but keep the sort-order of the default-language. the cause is, that alternativeSortingField only sorts the table `pages`.
i wrote a quick and dirty solution to my problem:
the behaviour of alternativeSortingField is right. it sorts the table-entries. so i made another directive called "alternativeSortingField2" which sorts the entries, after they are completely cummulated.
example:
menu = HMENU
menu {
entryLevel = 3
1 = TMENU
1 {
alternativeSortingField2 = title ASC
}
}
i changed the code of typo3/sysext/cms/tslib/class.tslib_menu.php in typo3 4.2.0 after line 831:
$altSortField2 = trim($this->mconf['alternativeSortingField2']);
if(isset($altSortField2) && $altSortField2 != '') {
$altSortField2 = preg_split('/[\\s,]+/s',$altSortField2);
if(!isset($altSortField21)) $altSortField21 = 'ASC';
else $altSortField21 = strtoupper($altSortField21);
$type = 'string';
foreach($temp as $gettype) {
if(isset($gettype[$altSortField20])) $type = gettype($gettype[$altSortField20]);
break;
}
$lFunc = 'return strcmp($a["'.$altSortField20.'"],$b["'.$altSortField20.'"]);';
if($type != 'integer' && $type != 'double') {
if($altSortField21 == 'DESC') {
$lFunc = 'return strcmp($b["'.$altSortField20.'"],$a["'.$altSortField20.'"]);';
}
} else {
if($altSortField21 'DESC') {
$lFunc = 'if ($a["'.$altSortField2[0].'"] $b["'.$altSortField20.'"]) { return 0; }'.
' return ($a["'.$altSortField20.'"] < $b["'.$altSortField20.'"]) ? -1 : 1;';
} else {
$lFunc = 'if ($a["'.$altSortField20.'"] == $b["'.$altSortField20.'"]) { return 0; }'.
' return ($b["'.$altSortField20.'"] < $a["'.$altSortField20.'"]) ? -1 : 1;';
}
}
$lambda = create_function('$a,$b',$lFunc);
uasort($temp,$lambda);
}
(issue imported from #M9606)
Files