[TYPO3-mvc] Ordering of Tx_Extbase_Persistence_ObjectStorage Objects
Michael Knoll
mimi at kaktusteam.de
Tue Apr 19 09:55:53 CEST 2011
Hi Falk,
as a default, the object storage objects are sorted by the key and
direction given in TCA (for a 1:m or m:n relation). If you want to have
something else, you can easily implement your own methods in your
repository, where you can use any field and direction you like for
sorting. Take a look at this snippet:
$query = $this->createQuery();
// not that important...
$constraints = array();
$constraints[] = $query->equals('item', $item->getUid());
$constraints[] = $query->equals('paramhash',
$resolutionConfiguration->getParameterHash());
// and now the most important line:
$query->setOrderings(array('FIELDNAME' =>
Tx_Extbase_Persistence_Query::ORDER_ASCENDING));
// let's get the ordered result
$result = $query->matching($query->logicalAnd($constraints))->execute();
Hope this helps!
Greetings
Mimi
Am 18.04.11 11:55, schrieb Falk Kühnel:
> Hi!
>
> Is there a way to order the objects returned in an Tx_Extbase_Persistence_ObjectStorage Object?
> You can do it in a repository, but what about those?
> Thanks for your help.
>
> Liebe Grüße
> Falk Kühnel
>
More information about the TYPO3-project-typo3v4mvc
mailing list