[TYPO3-ttnews] 3.0.1 - multi language orderby title

Claus Fassing claus at fassing.eu
Fri May 21 09:50:09 CEST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 10.05.2010 10:05, schrieb Claus Fassing:
> Hello,
> 
> in a multi language environment, default 'de' and alternate 'en', i try
> to sort a LIST view by title. For this i used the
> plugin.tt_news.listOrderBy = title
> setting which is working for 'de' as expected, but not for the 'en'
> translated title entries.
> The order for 'en' also come from 'de' titles and break the alphabetical
> order in 'en'
> 
> Is this case intended ?
> 
> Everything else language related things are working fine.
> 
> TYPO3 4.3.3

I check the getListContent function from class tx_ttnews and determined
that the data ever from default language fetched although a translation
was requested
By iterating through the records a function is called which fetch the
translated information. A listOrderBy = title will never work for
alternate language records.

Background : We need this for a faq list
http://www.rohloff.de/en/info/faq/speedhub_50014/misc/index.html

I did the following to get this work.

Right before :
// Getting elements
while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
[...]

// Note field and direction
list($sortField, $sortDirection) = explode(" ", $this->conf['listOrderBy']);
$sortField = strtolower($sortField);
$sortDirection = strtolower($sortDirection);


In the while loop i changed this line
$itemsOut .=
$this->cObj->substituteMarkerArrayCached($itemparts[$layoutNum],
$markerArray, array(), $wrappedSubpartArray);

to
if($GLOBALS['TSFE']->sys_language_content && $sortField == 'title'){
  			// Helper Array to sort localized entries by title
        $toSortArray[$markerArray['###NEWS_TITLE###']] =
array('item'=>$itemparts[$layoutNum],'marker'=>$markerArray,'subpart'=>$wrappedSubpartArray);
  		} else {
        // Store the result of template parsing in the Var $itemsOut,
use the alternating layouts
  			$itemsOut .=
$this->cObj->substituteMarkerArrayCached($itemparts[$layoutNum],
$markerArray, array(), $wrappedSubpartArray);
      }

And after the while loop :
if(!empty($toSortArray)){
      if($sortDirection == 'asc'){
        ksort($toSortArray);
      } elseif($sortDirection == 'desc'){
        krsort($toSortArray);
      }
      foreach($toSortArray as $key => $value){
        $itemsOut .=
$this->cObj->substituteMarkerArrayCached($value['item'],$value['marker'],array(),$value['subpart']);
      }
    }

I would be pleased about improvement suggestions.

Regards Claus
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJL9jsxAAoJELsIv+audObfaCcIAOOf+LOtSmRwoHA7kwgfScE9
Pz7aszdAI0H8nB5sc1mB6Vp3JXsNGgtkKGPc68DanklAM9RziYbQPBPaKGIh9SiL
g2kOKuF8NhDQx3qIk55P2B5O3OrvmKcolfdKbZXu/wsvVDOeoC13tib2PnEiStYR
g/ziWOGTWq+iCHZjUo8YOxZeVbDo4DbucgkQEzym9EB6QENhhrUPjFQ6eic47ITc
k2mFuNpVtsSZoJOry3OhiFnaNXKbXH6ovCm6qbo24a7ejAWX+OG02tiZ12ldQx12
tIl7kTm9Jtr/atj5aKQLa+LclwEji9/17/+md8m4VyBWNMxuB7KgcfRvUxkQJZo=
=+d0V
-----END PGP SIGNATURE-----


More information about the TYPO3-project-tt-news mailing list