fetch sorted by number of children

Author Message

Xavier Dutoit

Wednesday 29 March 2006 2:17:38 am

Hi,

I don't find any sort_by option that would allow me to sort the content by the number of children (eg. get the list of articles that got the most comments).

Am I blind ?

Any advice or suggestion on how to do it in a db friendly way more than welcome...

X+

http://www.sydesy.com

Marc Boon

Friday 31 March 2006 5:49:25 am

As a workaround, you could add an attribute (of type integer) to the article class which holds the number of comments. This attribute should then be incremented by template code every time a comment is posted. Then you can use attribute sorting while fetching the articles.

Kristof Coomans

Friday 31 March 2006 6:13:43 am

We should have an extended_sort_by like the extended_attribute_filter :-)

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Paul Borgermans

Friday 31 March 2006 8:08:47 am

Then write a patch for 3.8.1 ;-)) We will need this too for our internal portal: sort by the number of children and sort by the number of reverse related objects

Happy coding!

--paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Lyzy Lusterman

Tuesday 26 October 2010 9:41:51 am

I like Marc's workaround suggestion... I know this is an old post, but has anyone used his suggestion successfully? I would really appreciate it if Marc, or anyone else who knows, can explain to me how I can get the integer attribute in the parent node to be edited and updated automatically whenever a child object is added. Thanks!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.