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.

eZ debug

Timing: Jan 18 2025 04:59:44
Script start
Timing: Jan 18 2025 04:59:44
Module start 'layout'
Timing: Jan 18 2025 04:59:44
Module start 'content'
Timing: Jan 18 2025 04:59:46
Module end 'content'
Timing: Jan 18 2025 04:59:46
Script end

Main resources:

Total runtime1.3957 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 588.0313152.6406
Module start 'layout' 0.00640.0036 740.671939.4766
Module start 'content' 0.01001.3842 780.1484513.9219
Module end 'content' 1.39420.0014 1,294.070312.1406
Script end 1.3956  1,306.2109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.2469160.0002
Check MTime0.00130.0906160.0001
Mysql Total
Database connection0.00080.055810.0008
Mysqli_queries1.345996.4322620.0217
Looping result0.00070.0497600.0000
Template Total1.357997.320.6790
Template load0.00240.174920.0012
Template processing1.355597.119720.6777
Template load and register function0.00030.023810.0003
states
state_id_array0.00090.064410.0009
state_identifier_array0.00130.090420.0006
Override
Cache load0.00210.1481260.0001
Sytem overhead
Fetch class attribute can translate value0.00080.053730.0003
Fetch class attribute name0.00270.196040.0007
XML
Image XML parsing0.00030.022430.0001
class_abstraction
Instantiating content class attribute0.00000.000940.0000
General
dbfile0.00050.0393100.0001
String conversion0.00000.000740.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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/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: 15
 Number of unique templates used: 5

Time used to render debug report: 0.0002 secs