FlowQuery setOrdering

Hey guys,

how I can order the results in FlowQuery? setOrderings don’t work.

Thank you for your help!

(new FlowQuery(array($node)))->children('[instanceof TYPO3.Neos.NodeTypes:Page]')->context(array('workspaceName' => 'live'))->slice($queryOffset, $itemsPerPage)->get();

Good morning @patriceckhart,

try to use the SortOperation:

(new FlowQuery(array($node)))->children('[instanceof TYPO3.Neos.NodeTypes:Page]')->context(array('workspaceName' => 'live'))->slice($queryOffset, $itemsPerPage)->sort(property, "DESC")->get();

Note that this operation is not part of the default distribution. @stolle from which package did you have it?

1 Like

Indeed, didn’t realized that this was form an 3rd party package. The operation can be found here https://github.com/Flowpack/Flowpack.Listable/blob/master/Classes/Flowpack/Listable/TypoScript/Eel/FlowQueryOperations/SortOperation.php

Thank you. sort() works with the Flowpack.Listable Package.
But I could only sort properties. Is there a way to sort them by e.g. creationdatetime?

@patriceckhart creationdatetime is also a property, just a system property that starts with an underscore: https://github.com/neos/neos-development-collection/blob/master/TYPO3.Neos/Configuration/NodeTypes.yaml#L34
Write it as _creationDateTime and it should work.

Hi @patriceckhart,

my colleague @chri____ wrote a blog post on a similar topic some time ago, which might help you out a bit.
It’s written in german, hope that’s alright. Basically it’s about creating an inspector input field to define a property you want the ordering be based on.


Best wishes!

Thank you dimaip. _creationDateTime works but _sortingIndex dont work. The NodeTypes.yaml not included _sortingIndex

I have tried this, but filter does not work

$articles2 = (new FlowQuery(array($node)))->children('[instanceof TYPO3.Neos.NodeTypes:Page]')->context(array('workspaceName' => 'live'))->filter(array($node->getProperty('slider') => true))->sort('_sortingIndex', 'DESC')->slice($queryOffset, $itemsPerPage)->get();

Please note that what you are trying to do is much better done with one of the search implementations (ElasticSearch or SimpleSearch).

1 Like

Is there no possibility with Flowquery?

Check this package, it contains a FlowQuery opertation for sorting:


Using ElasticSearch will offer better performance, but for simple use case the raw PHP solution work fine

1 Like

Thank you!