Fetch multiple nodes with sort_by

Author Message

Håkan Bergman

Friday 13 August 2010 1:31:03 am

Hello,

I am fetching multiple articles and want to sort them by priority first and then when they were published. It looks like my template is ignoring the published statement in my template code.

Folder layout:

Articles
-> Articlecategory
--> Article
-> Articlecategory
--> Article

I am fetching the categories as parent_node's and want the articles to be sorted in priority and then when they were published.

{def $articles = fetch( 'content', 'list', hash( 'parent_node_id', array( '224', '63', '178' ), 'sort_by', array( 'priority', false()), array( 'published', false()) ) )}

This is my "hard coded" code that I test with. The first sort_by is fine, I tried to sort it by true() and even changed it to published -> priority, which works fine. Then the list is sorted by published but then priority is ignored.

I've tried to change it back and forth, using 'prioriry', false(), 'published', false() instead of 2 arrays. But nothing seem to work. Anyone knows what the correct syntax should look like?

Håkan

Carlos Revillo

Friday 13 August 2010 4:09:23 am

sort_by has to be a unique array. i mean, you need to pass one only array with probably some others arrays. something like

{def $articles = fetch( 'content', 'list', hash( 'parent_node_id', array( '224', '63', '178' ), 
                                                   'sort_by', 
                                                             array( 
                                                              array( 'priority', false()), 
                                                               array( 'published', false()) 
                                                              )
 ) )}

Best.

Håkan Bergman

Friday 17 September 2010 5:47:53 am

Thank you Carlos.

Worked like a charm!

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:08:12
Script start
Timing: Jan 18 2025 05:08:12
Module start 'layout'
Timing: Jan 18 2025 05:08:12
Module start 'content'
Timing: Jan 18 2025 05:08:13
Module end 'content'
Timing: Jan 18 2025 05:08:13
Script end

Main resources:

Total runtime0.8335 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 587.9219152.6250
Module start 'layout' 0.00650.0038 740.546939.4609
Module start 'content' 0.01030.8217 780.0078471.2734
Module end 'content' 0.83200.0015 1,251.281312.1563
Script end 0.8334  1,263.4375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3946160.0002
Check MTime0.00130.1520160.0001
Mysql Total
Database connection0.00090.110510.0009
Mysqli_queries0.782993.9298570.0137
Looping result0.00080.0906550.0000
Template Total0.797995.720.3990
Template load0.00200.245620.0010
Template processing0.795895.485520.3979
Template load and register function0.00020.018310.0002
states
state_id_array0.00100.122310.0010
state_identifier_array0.00100.115820.0005
Override
Cache load0.00170.2036230.0001
Sytem overhead
Fetch class attribute can translate value0.00080.096720.0004
Fetch class attribute name0.00130.161030.0004
XML
Image XML parsing0.00020.028620.0001
class_abstraction
Instantiating content class attribute0.00000.000730.0000
General
dbfile0.00150.1748100.0001
String conversion0.00000.001340.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/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
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.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: 6

Time used to render debug report: 0.0001 secs