sort within tree

Author Message

Nick Ursa

Thursday 21 December 2006 4:31:25 am

I'm having trouble getting ezpublish to respect the priority when using fetch content tree:

When I do:

{def $items=fetch( 'content', 'tree', hash( 'parent_node_id',$top_node_to_fetch,
                                            sort_by, array('priority', true())
                                             )))}

It doesn't sort each group of children but rather sorts the whole list after the initial search, destroying the hierarchy.

What I would have expected is that, starting from the parent node, it sorts the subchildren, outputs the first item, and checks for children, then sorting those subchildren, etc, before output. Currently fetch-tree behaves exactly like list.

All I want is to control the order of items within the tree. Any suggestions ?

Claudia Kosny

Thursday 21 December 2006 11:03:00 am

Hi Nick

If you check the SQL query that is created by this fetch function you can see that this is not possible. The result you want to have is only possible if you fetch the children of each child recursively with a separate query which is not possible with an eZ template function/operator (unless you write your own, which is fairly easy to do).

The only difference between tree and list is that list fetches only direct children of a node, otherwise they are the same.

Claudia

Piotrek Karaƛ

Wednesday 11 April 2007 3:24:39 pm

To be honest, I don't quite grasp the difference (or any useful difference to be precise) between list and tree content fetches. Both use the depth parameter, which makes them even more alike. And the name 'tree' is definitely misleading since there's little that we can do with the result as a tree. Can anyone give a useful example of tree fetch implementation?
Thanks!

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

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 31 2025 01:35:51
Script start
Timing: Jan 31 2025 01:35:51
Module start 'layout'
Timing: Jan 31 2025 01:35:51
Module start 'content'
Timing: Jan 31 2025 01:35:51
Module end 'content'
Timing: Jan 31 2025 01:35:51
Script end

Main resources:

Total runtime0.0233 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0045 588.0313151.1953
Module start 'layout' 0.00450.0042 739.2266220.6563
Module start 'content' 0.00870.0130 959.8828997.8984
Module end 'content' 0.02170.0016 1,957.781333.9922
Script end 0.0233  1,991.7734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002711.4514140.0002
Check MTime0.00114.6257140.0001
Mysql Total
Database connection0.00072.862110.0007
Mysqli_queries0.002510.623730.0008
Looping result0.00000.056210.0000
Template Total0.00114.810.0011
Template load0.00093.754110.0009
Template processing0.00021.067810.0002
Override
Cache load0.00062.566810.0006
General
dbfile0.00031.160880.0000
String conversion0.00000.033740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs