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.