[TYPO3-mvc] query->setOrderings: order by value list

Peter Niederlag typo3-list at niekom.de
Wed Jul 6 10:44:20 CEST 2011


Hello,

Am 05.07.2011 11:04, schrieb Franz Koch:
> Hey,
>
>> The customer is able to define a custom order of the entities in the
>> backend.
>>
>> In my person repository I have a function findByUids expecting a comma
>> separated list of uids (from the flexform value).
>>
>> Wouldn't it be nice to have the ability to call query->setOrderings
>> with the
>> provided list to define the ordering exactly as given in the backend?
>
> shouldn't the objects automatically be selected in the order you defined
> in the uid list? That's at least the case for me IIRC. Of course you
> must take care to not apply default orderings you probably set for your
> repository.

Consider a domain that has a default sorting by "name" and no manual 
sorting column available.

Now you want a "special" plugin where an editor can pick individual 
items from the list. As opposed to the default sorting you want them to 
be displayed in the order the editor has picked them. In TYPO3-BE this 
is possible and I think that's what Stephan has done.

@Stephan:
If extbase query model does not provide means to accomplish sorting by 
"order of the uids the editor has selected" you could spoof it by 
exploding the list of uids and quering each item individually and adding 
them to an array that your repository method returns:

// pseudo-code
findByUidListWithSorting($uidList) {
   $result = array();
   foreach(explode($uidList) as $uid) {
     $result[] = findByUid($uid);
   }
   return $result;
}


Greets,
Peter
-- 
Peter Niederlag
http://www.niekom.de * TYPO3 & EDV Dienstleistungen *


More information about the TYPO3-project-typo3v4mvc mailing list