Fetching and sorting nested articles

Author Message

Alessandro Ranellucci

Monday 21 April 2003 2:49:49 pm

Suppose I have articles organized in folders (topics). On my home page I want to list them in descending order (most recent first), but I want to group them by topic. I'd need some way to sort folder list by {date of last article in each}.

How?

sergey podlesnyi

Tuesday 22 April 2003 3:12:52 am

Naturally, give each topic folder node_id to fetch statement as parent_node_id. If all your topic folders sit in one "Topics" folder, you can write nested loops - outer loop scans all topis and inner loop - each article in given topic.

There was tricky syntax for nested loops in pre-final releases when I tried them, don't know if this is fixed now. Generally, it should look like this:
(assuming 10 is node id of your TOPICS folder)

{let topics_list=fetch(content, list, hash(parent_node_id, 10))}
{section name=topics loop=fetch(content, list, hash(parent_node_id, $topics_list))}
{section loop=fetch(content, list, hash(parent_node_id, $topics:item.node_id))}
{node_view_gui view=line content_node=$topics:item}
{/section}
{/section}
{/let}

This code is not tested so please do it yourself!

Alessandro Ranellucci

Tuesday 22 April 2003 4:41:49 am

Hmm. Thanks Sergey for the code. However I'm not sure that it helps me: I'm looking for some way to sort a folder list by {date of last article in each}; those folders will be traversed only when I get them in right order. Is the "modified" node attribute updated when a child node is added to it?

Mikhail Lukyanchenko

Thursday 08 May 2003 8:54:15 am

>Hmm. Thanks Sergey for the code. However I'm not sure that it
>helps me: I'm looking for some way to sort a folder list by
>{date of last article in each}; those folders will be traversed
>only when I get them in right order. Is the "modified" node
>attribute updated when a child node is added to it?
No, it is not. AFAIK the only way to update parent node's modification time is creating custom workflow.

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