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.

eZ debug

Timing: Jan 18 2025 05:02:20
Script start
Timing: Jan 18 2025 05:02:20
Module start 'layout'
Timing: Jan 18 2025 05:02:20
Module start 'content'
Timing: Jan 18 2025 05:02:21
Module end 'content'
Timing: Jan 18 2025 05:02:21
Script end

Main resources:

Total runtime1.1014 sec
Peak memory usage4,096.0000 KB
Database Queries69

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0090 589.0391152.6250
Module start 'layout' 0.00900.0035 741.664139.4609
Module start 'content' 0.01251.0875 781.1250670.2578
Module end 'content' 1.10000.0014 1,451.382812.1563
Script end 1.1014  1,463.5391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.3609160.0002
Check MTime0.00150.1376160.0001
Mysql Total
Database connection0.00110.102410.0011
Mysqli_queries1.041694.5710690.0151
Looping result0.00080.0766670.0000
Template Total1.057696.020.5288
Template load0.00220.201520.0011
Template processing1.055395.813520.5277
Template load and register function0.00010.009910.0001
states
state_id_array0.00160.148310.0016
state_identifier_array0.00150.132820.0007
Override
Cache load0.00180.1627210.0001
Sytem overhead
Fetch class attribute can translate value0.00090.081750.0002
Fetch class attribute name0.00110.101580.0001
XML
Image XML parsing0.00150.134950.0003
class_abstraction
Instantiating content class attribute0.00000.001280.0000
General
dbfile0.00240.2144290.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs