Query builder for query on documents - order by children order, as when using getChildren()

26 views
Skip to first unread message

Joschi 127

unread,
Oct 24, 2016, 12:18:19 PM10/24/16
to symfony-...@googlegroups.com
Hi all,

we are using query builder to query for documents and joining with another type of document, and setting several conditions. Works fine. (In dead running fine since about 2 years now already and even with a lot of documents.)

However now we want to order the documents by their defined order - the same order as when using getChildren() of the parent document.

How can this be done when using the query builder?

All matching documents have the same parent.


Thanks a lot

Joschi



Daniel Leech

unread,
Oct 24, 2016, 1:50:36 PM10/24/16
to symfony-...@googlegroups.com
We had the same problem when I was working on Sulu CMS. AFAIRC it is an
implementation detail, there is apparently a switch in Jackrabbit to
enable "natural ordering", we could not, however, get this to work.

Our solution was to add a subscriber which set an integer value on the
document, and then order on that field:

https://github.com/sulu/sulu/blob/develop/src/Sulu/Component/Content/Document/Subscriber/OrderSubscriber.php#L96
> --
> You received this message because you are subscribed to the Google Groups
> "symfony-cmf-devs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [1]symfony-cmf-de...@googlegroups.com.
> For more options, visit [2]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:symfony-cmf-de...@googlegroups.com
> 2. https://groups.google.com/d/optout

Joschi 127

unread,
Oct 24, 2016, 4:10:11 PM10/24/16
to symfony-...@googlegroups.com
Okay - thanks for your response. We also thought about just using an additional integer value but we were wondering if there isn't a way to do this using the query builder.

But I think we can live with an integer value at least for now.

Thanks

Joschi

Joschi 127

unread,
Oct 24, 2016, 4:13:27 PM10/24/16
to symfony-...@googlegroups.com
PS: Your way of doing this in a subscriber is nice of course. Thanks for the direct link to the code.
Reply all
Reply to author
Forward
0 new messages