Sort fetch by multiple attributes

Author Message

Eivind Marienborg

Monday 13 November 2006 12:31:42 am

Hi!

I would like to do a fetch, and sort it first by priority, then by date. So if that I have a node with priority 10, and the rest is 0, the one with 10 is prioritized even though its published date is older then the ones with 0.

I have tried this:

{let page_limit=16
    children=fetch('content','list',hash( parent_node_id, $node.node_id,
                                          sort_by, array(array('priority','published'),true()),
                                          limit, $page_limit,
                                          offset, $view_parameters.offset
))}

But this makes it not sort at all. I have checked the debug output, but there doesn't seem to be any output of any error.

Is this kind of sorting mechainsm possible at all, and if so, how?

Jacobo Quiles

Monday 13 November 2006 1:04:51 am

Hi,

Try this:

children=fetch('content','list',hash( parent_node_id, $node.node_id,
sort_by, array(array( 'priority', true() ), array( 'published', true() )),
limit, $page_limit,
offset, $view_parameters.offset))}

Microblau SL
http://www.microblau.net

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 11:38:07
Script start
Timing: Jan 18 2025 11:38:07
Module start 'layout'
Timing: Jan 18 2025 11:38:07
Module start 'content'
Timing: Jan 18 2025 11:38:08
Module end 'content'
Timing: Jan 18 2025 11:38:08
Script end

Main resources:

Total runtime0.8332 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 587.9375152.6250
Module start 'layout' 0.00510.0050 740.562539.4453
Module start 'content' 0.01010.8217 780.0078531.4844
Module end 'content' 0.83180.0014 1,311.49228.1563
Script end 0.8332  1,319.6484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4052160.0002
Check MTime0.00150.1773160.0001
Mysql Total
Database connection0.00080.091210.0008
Mysqli_queries0.778393.4061540.0144
Looping result0.00050.0559520.0000
Template Total0.801196.220.4006
Template load0.00240.283420.0012
Template processing0.798895.868120.3994
Template load and register function0.00040.045110.0004
states
state_id_array0.00160.191210.0016
state_identifier_array0.00100.122620.0005
Override
Cache load0.00200.2394180.0001
Sytem overhead
Fetch class attribute can translate value0.00110.128820.0005
Fetch class attribute name0.00130.160840.0003
XML
Image XML parsing0.00210.255020.0011
class_abstraction
Instantiating content class attribute0.00000.000740.0000
General
dbfile0.00180.2217230.0001
String conversion0.00000.001140.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
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs