[TYPO3-mvc] Sorting for objectStorage

Toke Herkild th at t3cms.dk
Fri Nov 2 10:22:39 CET 2012


Den 02-11-2012 09:26, Toke Herkild skrev:
> Hi all,
>
> Any progress on the foreigb_sortby and DESC ?
>
> Default behavior of foreign_sortby is ASC, I've a child which needs to
> be fetched DESC as it's datetime based records, and the latest are the
> most important.
>
> Trying to do:
> $model->getDatetimechildren()
> I find I've only 2 options: 1) have them listed in default sql order
> (creation order) or foreign sortby (fieldname, and the Default ASC)
>
> I'm using extBase 1.3.3, and defaultOrderings doesn't seem to do it either.
>
> Regards,
> Toke

Hi all,

As a follow up, I've decided to use Tim Schochs solution from 28/10-2010 
changing:

Tx_Extbase_Persistence_Mapper_DataMapper::getPraparedQuery()

if ( preg_match( '#(.*?) (DESC|ASC)?$#i', 
$columnMap->getChildSortByFieldName(), $field ) ) {
     if ( 'DESC' == strtoupper( $field[2]) ) {
         $ordering = 
Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING;
     } else {
         $ordering = 
Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING;
     }
     $query->setOrderings(array( $field[1] => $ordering ));
} else {
     $query->setOrderings(array($columnMap->getChildSortByFieldName() => 
Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING));
}

It's not correct, it's not pretty... there's alot of things it isn't, 
but it does the job.

Cheers,
Toke


More information about the TYPO3-project-typo3v4mvc mailing list