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();
stolle
(Johannes Steu)
February 11, 2016, 8:20am
2
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();
christianm
(Christian Müller)
February 11, 2016, 2:38pm
3
Note that this operation is not part of the default distribution. @stolle from which package did you have it?
1 Like
stolle
(Johannes Steu)
February 11, 2016, 3:31pm
4
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?
dimaip
(Dmitri Pisarev)
February 12, 2016, 12:38pm
6
@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.
saR
(Sarah Rehbock)
February 14, 2016, 10:57am
7
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.
https://portachtzig.com/de/blog/nodes-nach-bestimmten-kriterien-abrufen-und-sortieren.html
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();
christianm
(Christian Müller)
February 15, 2016, 2:26pm
9
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?
dfeyer
(Dominique Feyer)
March 24, 2016, 4:05pm
11
Check this package, it contains a FlowQuery opertation for sorting:
https://packagist.org/packages/ttree/contentrepositoryutility
Using ElasticSearch will offer better performance, but for simple use case the raw PHP solution work fine
1 Like