Bug #19483

Updated by Christian Kuhn over 5 years ago

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($altSortField2[1])) $altSortField2[1] = 'ASC'; 
	 else $altSortField2[1] = strtoupper($altSortField2[1]); 
	 $type = 'string'; 
	 foreach($temp as $gettype) { 
		 if(isset($gettype[$altSortField2[0]])) $type = gettype($gettype[$altSortField2[0]]); 
		 break; 
	 } 
	 $lFunc = 'return strcmp($a["'.$altSortField2[0].'"],$b["'.$altSortField2[0].'"]);'; 
	 if($type != 'integer' && $type != 'double') { 
		 if($altSortField2[1] == 'DESC') { 
			 $lFunc = 'return strcmp($b["'.$altSortField2[0].'"],$a["'.$altSortField2[0].'"]);'; 
		 } 
	 } else { 
		 if($altSortField2[1] == 'DESC') { 
			 $lFunc = 'if ($a["'.$altSortField2[0].'"] == $b["'.$altSortField2[0].'"]) { return 0; }'. 
				 ' return ($a["'.$altSortField2[0].'"] < $b["'.$altSortField2[0].'"]) ? -1 : 1;'; 
		 } else { 
			 $lFunc = 'if ($a["'.$altSortField2[0].'"] == $b["'.$altSortField2[0].'"]) { return 0; }'. 
				 ' return ($b["'.$altSortField2[0].'"] < $a["'.$altSortField2[0].'"]) ? -1 : 1;'; 
		 } 
	 } 
	 $lambda = create_function('$a,$b',$lFunc); 
	 uasort($temp,$lambda); 
 } 




 




 (issue imported from #M9606)

Back